Re: how do I send a post string
From: Don Andrez (DonAndrez_at_discussions.microsoft.com)
Date: 03/09/05
- Next message: Steve Gould: "Trying to use JScript Eval to construct an expression from a string."
- Previous message: Juan: "HTTPS with Smartphone"
- In reply to: Alex Feinman [MVP]: "Re: how do I send a post string"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Mar 2005 02:55:02 -0800
I need something that will send a post string like this:
POST /example-test/example.php HTTP/1.1
Host: don
Connection: Keep-Alive, TE
TE: trailers, deflate, gzip, compress
User-Agent: RPT-HTTPClient/0.3-3E
Cookie: GallerySession=4ca4085148c93f808cb620e515245974
Cookie2: $Version="1"
Accept-Encoding: deflate, gzip, x-gzip, compress, x-compress
Content-type: multipart/form-data;
boundary=--------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-----
Content-length: 43183
----------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-----
Content-Disposition: form-data; name="cmd"
add-item
----------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-----
Content-Disposition: form-data; name="protocol_version"
2.3
----------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-----
Content-Disposition: form-data; name="set_albumName"
test1
----------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-----
Content-Disposition: form-data; name="caption"
----------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-----
Content-Disposition: form-data; name="force_filename"
bridge.jpg
----------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-----
Content-Disposition: form-data; name="userfile"; filename="res-1265080177.jpg"
Content-Type: image/jpeg
*** a whole bunch of data: the contents of the file, in binary format ***
----------ieoau._._+2_8_GoodLuck8.3-ds0d0J0S0Kl234324jfLdsjfdAuaoei-------
"Alex Feinman [MVP]" wrote:
> Use HttpWebRequest.GetRequestStream and then write into that stream. Close
> it when you are done. Might be easier to create a StreamWriter on it with
> appropriate encoding
> Something like this:
>
> Uri target = new Uri(args[0]);
> HttpWebRequest req = HttpWebRequest.Create(target) as HttpWebRequest;
> req.Method = "POST";
> req.ContentType = "application/x-www-form-urlencoded";
> Stream st = req.GetRequestStream();
> StreamWriter wrt = new StreamWriter(st, Encoding.ASCII);
> wrt.Write("destination=" + args[0]);
> wrt.Write("&flags=14"); // Rich client (1 - basic client)
> Console.Write("user: ");
> wrt.Write("&username=" + Console.ReadLine());
> Console.Write("password: ");
> wrt.Write("&password=" + Console.ReadLine());
> wrt.Write("&submit=submit");
> wrt.Close();
> st.Close();
> HttpWebResponse rsp = req.GetResponse() as HttpWebResponse;
> st = rsp.GetResponseStream();
> StreamReader rdr = new StreamReader(st);
> Console.WriteLine(rdr.ReadToEnd());
>
>
> --
> Alex Feinman
> ---
> Visit http://www.opennetcf.org
> "Don Andrez" <Don Andrez@discussions.microsoft.com> wrote in message
> news:193CA17F-5793-4ABC-8560-BD6BC36014BF@microsoft.com...
> > How do i send a post string in c# .net cf
> > i need to send a multipart/form-data to a web server and get its response
> >
>
>
- Next message: Steve Gould: "Trying to use JScript Eval to construct an expression from a string."
- Previous message: Juan: "HTTPS with Smartphone"
- In reply to: Alex Feinman [MVP]: "Re: how do I send a post string"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|