Re: How to retrieve raw HTTP Post Data



in the html payload, the cookie is in the header, and is just before the
postdata. the url parameters are actuallly on the same line as action
(GET/POST).

see the Request object, you can get the cookie, headers and querystring
(parsed/unparsed).

-- bruce (sqlwork.com)


"manheim@xxxxxxxxx" wrote:

Thanks! That looks like it will do the trick.
The one challenge is that I am also getting data through QueryString.
It looks like using InputStream will put all POST and GET data (and
presumably other Request data like Cookies) together into one file.
I assume that's what's happening since I can't open the jpg after I
save it out.

Is there a way to separate the POST data?

Dan

On Nov 15, 12:48 pm, bruce barker (sqlwork.com)
<brucebarkersqlwork...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
use Request.InputStream:

FileStream log = new FileStream("C:\\dump.tmp",
FileMode.OpenOrCreate);
byte[] buffer = new byte[1024];
int c;
while ((c = Request.InputStream.Read(buffer, 0, buffer.Length)) > 0)
{
log.Write(buffer, 0, c);
}
log.Close();

-- bruce (sqlwork.com)

"manh...@xxxxxxxxx" wrote:
I have a page posting a raw jpg to me via HTTP POST. All reference
I've found is centered around retrieving POST data as name/value pairs
which will not work in this situation.
What I need to do is retrieve the raw POST data and save it as a
jpg.

Here is some php code that does the same thing for reference:
$jfh = fopen($jpeg_file, 'w') or die("can't open file");
fwrite($jfh, $GLOBALS['HTTP_RAW_POST_DATA']);
fclose($jfh);

I assume there is some way to access POST data as a stream and then
write that stream to a file, but it's not clear to me how. Perhaps I
need to use Request.Form.GetObjectData, but I'm not sure how to setup
SerializationInfo and StreamingContext appropriately.

Any thoughts or suggestions would be much appreciated.
Thanks in advance!

Dan


.



Relevant Pages

  • Re: Post Without Return
    ... open up a socket, ... just add code to send POST data, it is in the header just like a GET, last ... > I have used fsockopenand cURL for posting to remote servers where I> wanted to get a return value, but how do you post to a remote server> programatically where you want to go to the result page on that> server? ...
    (alt.php)
  • Re: Redirect with POST
    ... a location header is included to show the url to go to. ... "Thom Little" wrote: ... just javascript in the page. ... POST data (i.e., formatted like a form. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: "Warning: Page has Expired" - How to aviod when using browserback button?
    ... The visitor's browser will have to submit the POST data twice ... Sending a "Location" header with PHP simply isn't good ... phil [dot] ronan @ virgin net ...
    (comp.lang.php)
  • Re: post image to webhoster - upload file with http
    ... I want to upload an image to imageshack in C++. ... where I can specify a url, post data and header. ... String boundary, sHeader, sPostData, sFileContent; ...
    (alt.php)
  • Re: Fairly serious vulnerability in vBulletin 2.2.0
    ... > Ensure that $bbuserid, $bbpassword, and the rest of the cookied variables ... > are coming from the cookie and not from GET or POST data, ... create your own cookie jar with the appropriate data. ...
    (Bugtraq)