[Mono-dev] HttpWebRequest method patch

Atsushi Eno atsushi at ximian.com
Mon Jan 29 05:16:04 EST 2007


Well, it is very good idea to report this BUG to Microsoft and
let them fix it. I will do that unless someone points out that
our (a couple of lingr users') interpretation is wrong.

I rather want judgement of the spec situation: whether HTTP methods
like "posT" must retrieve request/response stream like POST.

(As usual I'm not interested in making silly changes to our code.)

Atsushi Eno

Gert Driesen wrote:
> Hi Atushi,
> 
> I noticed something similar for FileWebRequest, where methods are handled 
> case-insensitive too.
> 
> I'd suggest adding unit tests which verify the MS behavior, and modify our 
> HttpWebRequest accordingly.
> 
> We could then still report it as an issue to MS (using 
> connect.microsoft.com), and the unit test would alert us if/when MS changes 
> their (broken) behavior (but this is unlikely to happen, as it could break 
> existing code).
> 
> I'll take care of the unit tests (later), if you want to.
> 
> Gert
> 
> ----- Original Message ----- 
> From: "Atsushi Eno" <atsushi at ximian.com>
> To: <mono-devel-list at lists.ximian.com>
> Sent: Monday, January 29, 2007 12:46 AM
> Subject: [Mono-dev] HttpWebRequest method patch
> 
> 
>> Hi,
>>
>> I have a patch for HttpWebRequest.cs which might be problematic.
>>
>> HttpWebRequest differentiates request/response stream processing
>> based on the method (POST/PUT etc.). .NET actually handles things
>> like "post" as POST and thus with such methods it uses POST-style
>> processing.
>>
>> The attached patch makes HttpWebRequest to work along that way,
>> but to me it looks like HTTP RFC (2616) violation.
>>
>> (I noticed this issue when trying to get Lingr API .NET wrapper ==
>> http://www.legendes.jp/lingr/api.net/ . The source will be fixed
>> anyways.)
>>
>> Atsushi Eno
>>
> 
> 
> --------------------------------------------------------------------------------
> 
> 
>> Index: System.Net/HttpWebRequest.cs
>> ===================================================================
>> --- System.Net/HttpWebRequest.cs (revision 71778)
>> +++ System.Net/HttpWebRequest.cs (working copy)
>> @@ -372,7 +372,23 @@
>>  if (value == null || value.Trim () == "")
>>  throw new ArgumentException ("not a valid method");
>>
>> - method = value;
>> + // LAMESPEC: This class is not really case
>> + // sensitive for those methods here, which
>> + // would violate RFC 2616 (5.1.1).
>> + string upper = value.ToUpperInvariant ();
>> + switch (value.ToUpperInvariant ()) {
>> + case "GET":
>> + case "POST":
>> + case "PUT":
>> + case "HEAD":
>> + case "CONNECT":
>> + case "MKCOL":
>> + method = upper; // case sensitive
>> + break;
>> + default:
>> + method = value; // case insensitive
>> + break;
>> + }
>>  }
>>  }
>>
>>
> 
> 
> --------------------------------------------------------------------------------
> 
> 
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 




More information about the Mono-devel-list mailing list