Hi, I've written a podcast retriever app that uses HttpWebRequest. Create (URL), httpWebRequest. GetResponse() and httpWebResponse .GetResponseStr eam() 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 AllowAutoRedire ct 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 AllowAutoRedire ct 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/dd0b3a533786a68 b/POI_2012_02_06_ Lawrence_
Krauss.mp3?sid= 754a6272b039a82 de7ae5d76b6b910 8a&l_sid=18988& l_eid=&l_mid=28 93533
&expiration=132 8800427&hwt=0d5 ab5ea055869ea39 825edcd5b2e338
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.ce00 4s1
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.l ibsyn.com
Vary:Accept-Encoding
Connection:clos e
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.
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/dd0b3a533786a68 b/POI_2012_02_06_ Lawrence_
Krauss.mp3?sid= 754a6272b039a82 de7ae5d76b6b910 8a&l_sid=18988& l_eid=&l_mid=28 93533
&expiration=132 8800427&hwt=0d5 ab5ea055869ea39 825edcd5b2e338
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.ce00 4s1
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.l ibsyn.com
Vary:Accept-Encoding
Connection:clos e
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.
Comment