[Mono-list] Who is wrong, mono or microsoft

kuse marcus at in-process.se
Tue Sep 1 04:48:03 EDT 2009




SomeIrishGuy wrote:
> 
> Hi
> 
> I have been implementing a desktop application that requests information
> from a website.
> 
> The particular problem is sending post information with a query string and
> the underlying http protocol implementation
> 
> consider the following code snippet
> --------------------------------------------------------------------------------------------------------
> 
> ASCIIEncoding encoding = new ASCIIEncoding();
> string postData = "user=" + this.modem_user + "&pass=" +
> this.modem_password + "&submit=SUBMIT";
> 
> byte[] data = encoding.GetBytes(postData);
> 
> string dailyimage =
> "http://support.smarttelecom.ie/forums/smart_usage.php?img=daily";
> HttpWebRequest requestImage2 = (HttpWebRequest)
> WebRequest.Create(dailyimage);
> requestImage2.CookieContainer = this.vbCookie;
> 
> requestImage2.Method = "POST";
> requestImage2.ContentType = "application/x-www-form-urlencoded";
> requestImage2.UserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US;
> rv:1.9.1.4pre) Gecko/20090829 Ubuntu/9.04 (jaunty) Shiretoko/3.5.4pre";
> requestImage2.ContentLength = data.Length;
> 
> 
> 
> // write POST to the stream	
> Stream newStream = requestImage2.GetRequestStream();
> newStream.Write(data, 0, data.Length);
> newStream.Close();
> 
> // what im trying to get is the image (but the query string is being
> ignored so this is to show the html)
> HttpWebResponse WebResp2 = (HttpWebResponse)requestImage2.GetResponse();
> Stream htmlStream = WebResp2.GetResponseStream();
> StreamReader html = new StreamReader(htmlStream);
> Console.WriteLine(html.ReadToEnd());
> 
> // save the image returned   (mono correctly gets the image)          
> System.Drawing.Image webImage2 =
> Image.FromStream(WebResp2.GetResponseStream());		
> webImage2.Save("daily.png");
> Console.WriteLine("saved image");
> WebResp2.Close();
> 
> -------------------------------------------------------------------------------------------------------
> 
> 
> 
> this snippet sends login information in the form of POST and has GET
> requests also in the form of a QUERY string
> 
> // string dailyimage =
> "http://support.smarttelecom.ie/forums/smart_usage.php?img=daily";
> 
> 
> -----------------------------------------------------------------------------------------------------------
> The problem
> -----------------------------------------------------------------------------------------------------------
> 
> mono sends the post information correctly and the query string is sent
> correctly as a get request as seen in wireshark
> 
>  http://www.nabble.com/file/p25230391/mono.png 
> 
> .net frame work sends the posts information but the query string is
> ignored by the server as the TCP http protocol is POST
> 
> as seen here
> 
>  http://www.nabble.com/file/p25230391/microsoft.png 
> 
> 
> 
> 

I maybe not have an answear here but I want to reflect a thing that came to
my mind.
If we look at the query string:
string dailyimage =
"http://support.smarttelecom.ie/forums/smart_usage.php?img=daily"; 
that's for me no doubt a GET-query string, but later the HttpWebRequest
method
is set to POST (requestImage2.Method = "POST";).
So my question is: Is it possible to have both GET and POST at the same
time? If not could it be that mono identifies the method from the query
string as GET and ignores the "requestImage2.Method = "POST"" ?




-- 
View this message in context: http://www.nabble.com/Who-is-wrong%2C-mono-or-microsoft-tp25230391p25236600.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list