views:

210

answers:

2

I am trying to write an IHttpHandler that can work with a request for streaming media coming from Windows Media Player/Silverlight. That means responding to a raw HTTP request like this (taken from the protocol document)

"GET /ms/contoso_100_files/0MM0.wmv HTTP/1.0"
"Accept: */*"
"User-Agent: NSPlayer/4.1.0.3925"
"Host: netshow.micro.com"
"Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=1,max-duration=0"
"Pragma: xClientGUID={2200AD50-2C39-46c0-AE0A-2CA76D8C766D}"

When I land in the ProcessRequest method, the context.Request.Headers collection does not seem to expose the Pragma values. Further, it can never really do it as there are two lines with the same key (Pragma)!

I am assuming that if I can get the original packet I could parse these out manually.

That said, the next thing I want to do with it is construct a secondary request of type HttpWebRequest. That also sports a similiar dictionary which I expect will also not be able to accept the two identical pragma values without one overwriting the other.

Am I missing something?

A: 

The fact that there are no Pragma headers makes me think they might not be getting sent. I suggest you use Fiddler to watch the network traffic to make sure they're being sent to you.

John Saunders
A: 

How are you accessing Request.Headers? The NameValueCollection handles cases of multiple headers but you have to use the right members to access them:

string[] values = context.Request.GetValues("Pragma");

(The index property essentially performs a join(','...) where there are multiple values).

Richard
Thanks, I just tried this and it works:HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/whatever.html");request.Headers.Add(HttpRequestHeader.Pragma, "Blah1");request.Headers.Add(HttpRequestHeader.Pragma, "Blah2");Which solves the second question, John
John OHalloran