Q1 - Is this a bug in .net, or is the webserver I'm using for testing ( Mongoose ) not server up the header field Last-Modified in the format it should?
So in C# VS2008 if I make the call:
response = (HttpWebResponse)request.GetResponse();
Console.Out.WriteLine(" - LM = " + response.LastModified);
I get: ProtocolViolationException: The value of the date string in the header is invalid
When I use HTTPLiveHeaders to look at the HTTP head for last-modified I see:
Last-Modified: Fri, 20 Nov 2009 15:53:16 E. Australia Standard Time
Q2 - Any suggestions on how to handle so my unit tests which rely on using the Mongoose server won't have this issue?
Q3 - Anyone know if this is something that could happen on production internet web servers a lot? i.e. should I be assuming some webservers will give the Last-Modified field back in a different sort of format that .net will balk at?
Q1)
If you refer to the RFC 2616 Section 14, you'll see that the definition of the Last-Modified header is:
HTTP-date is specified in the same RFC, section 3.
Since the date in your header matches the first of these, with only the time zone looking different, you can check RFC 1123 to see if it's legal. Regarding time zones, this states.
From RFC 822 Section 5 we can see the definition of the zone:
As the time zone in the header is not listed here, we can therefore conclude that it is invalid, and that the server is in fact violating the protocol, so the exception appears reasonable.
Q2)
I'm afraid I don't know how you could handle it other than putting a proxy in the way that fixes up the header to be valid, or ask the people who write/maintain the Mongoose server to fix it (or fix it yourself and submit a patch, as it's an open source project).
Q3)
I've rarely (if ever) seen a web server that .NET has had problems calling, so I don't believe this type of issue is common on the internet in general.