473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

HttpWebRequest.GetResponse redirection problem

Hi, I've written a podcast retriever app that uses HttpWebRequest.Create (URL), httpWebRequest.GetResponse() and httpWebResponse.GetResponseStream() to retrieve podcast (.mp3) files from various web sites. As long as there is no URL redirection, the app works fine. When there is redirection, GetResponse goes astray (whether AllowAutoRedirect is True or False) and ends up pointing to an html file rather than to the podcast. The problem seems to be in the headers information returned by GetResponse. If I set AllowAutoRedirect to False and follow the redirection manually (by examining the httpWebResponse.Headers), I find that the header info doesn't match what I get when I use CURL to follow the redirection on the same URL.

For example, here's the CURL -I -L output for the URL:http://traffic.libsyn.com/pointofinquiry/POI_2012_02_06_Lawrence_Krauss.mp3

HTTP/1.0 302 Found
Date: Thu, 09 Feb 2012 14:30:41 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: PHP/5.3.8-ZS5.5.0 ZendServer/5.0
Location: http://hw.libsyn.com/p/d/d/0/dd0b3a533786a68b/POI_2012_02_06_Lawrence_
Krauss.mp3?sid=754a6272b039a82de7ae5d76b6b9108a&l_ sid=18988&l_eid=&l_mid=2893533
&expiration=1328800427&hwt=0d5ab5ea055869ea39825ed cd5b2e338
X-Libsyn-Host: traffic3.libsyn.com
Vary: Accept-Encoding
Connection: close
Content-Type: text/html

HTTP/1.0 200 OK
Date: Thu, 09 Feb 2012 14:28:37 GMT
Connection: close
Accept-Ranges: bytes
ETag: "1328572856"
Last-Modified: Tue, 07 Feb 2012 00:00:56 GMT
Expires: Fri, 10 Feb 2012 14:28:37 GMT
Content-Length: 15579891
Content-Type: audio/mpeg
X-HW: 1328797717.ce004s1

Note that there is one redirection here and that CURL correctly follows the redirection to the location where the mp3 file is located.

In my program, when I run this URL through the code, the header output returned is:

X-Libsyn-Host:traffic3.libsyn.com
Vary:Accept-Encoding
Connection:close
Content-Length:912
Content-Type:text/html
Date:Thu, 09 Feb 2012 14:51:10 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By:PHP/5.3.8-ZS5.50 ZendServer/5.0


Note that this is the same as the first portion of the CURL output, but Location is missing. Without a Location value, the redirection ends (because there is nowhere to go). As a result the GetResponse fails to get to the URL that actually points to the mp3 file.

Anybody know what's going on here? Is there a HttpWebRequest or HttpWebResponse property that I need to set to some nondefault value to get GetResponse to return Location values? Is there possibly some incompatibility between Apache servers and the .NET code that's causing GetResponse to return bad header data? Any suggestions for how to fix this would be much appreciated. Thanks.
Feb 9 '12 #1
1 2994
!NoItAll
297 100+
oooh please place your code within code blocks (click on the # sign to create a code block) - it is so hard for these old eyes to follow the flow of all left justified code... (I'm not sure I can help you, but being able to easily see your code flow is pretty important...).
Feb 13 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: R Reyes | last post by:
I am trying to code a file uploader (for forum/email attachments) from the client computer to a remote web server via the PUT method (since POST is not allowed ). However, the upload works ONLY...
1
by: Jeff B | last post by:
I'm trying to create a simple screen scraping application and I kept getting a System.Net.WebException thrown back with a message of "The operation has timed-out." At first I thought it was some...
5
by: japslam japslam via DotNetMonster.com | last post by:
Hi all, I have problem when I use HttpWebRequest and take long time to call to my service server. If at that time there are many request comes in semultaneous, I will get this exception ...
2
by: Steve Richter | last post by:
I have a page that uses simple HTTP GET to do an ISBN lookup via Amazon.com. The page works when I run it from //localhost. But I have moved it to my godaddy.com shared hoster site, and I get...
2
by: GlennLanier | last post by:
Hello, I've searched the forums and can't find an answer -- if it i there, kindly point me in that direction. I would like to simulate a browser POSTing a FORM and be able to pars the response....
0
by: Veerle | last post by:
Hi, On the website of the Belgian lottery, you can download an excel sheet with lottery results (the winning numbers) over the years and an excel sheet with financial results (the winnings) over...
1
by: MikeZ | last post by:
I post this question last week, no good answer, so I post again. Sorry about this. I use WebRequest.Create/WebRequest.GetResponse to handle HTTP request in a VS2003 project. I got HTTP violation...
1
by: Morgan Cheng | last post by:
When the function HttpWebRequest.GetResponse() is called, what happened? I mean, does this function return till all HTTP response is downloaded to local machine? or only HTTP header part retrived...
4
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi, I've run into a set of errors I don't understand coming back from HttpWebRequest.GetResponse, In one case, null is returned from the request without an Exception and in the other the request...
3
by: FreddyMack | last post by:
Two questions: 1) In Silverlight 4.0 Beta, I cannot find HttpWebRequest.GetResponse() ... any ideas where the functionality may be? I have found the Async form, but not the Sync form. 2) Within...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.