views:

188

answers:

3

I've seen a couple of rest examples where the xml message gets posted in the body of the http request, and not in a named parameter...

in classic asp I have the request.form object that allows me to get the posted values, but I have to specify the name of the parameter...

is there some way to get the whole content of the post?

I would need the equivalent of

request.serverVariables("QUERY_STRING"), but for the post, not the get part of the http request...

( http://www.w3schools.com/ASP/coll_servervariables.asp )

would I have to use request.binaryRead()???

thanks a lot

ps: in java, I cold achieve this using request.getReader()... http://stackoverflow.com/questions/1004442/how-to-get-a-the-value-of-an-http-post-as-a-whole-parsing-restful-post/1004522#1004522

--

just to clarify thing a little bit

when I say post a value as the body, I mean that the content of the message is not enconded like param1=value1&param2=value2...paramx=valuex

the message is the body itself... you can achieve this with any ajax library (like prototype) to test ir I'm using a firefox plugin that let you do that, it's named POSTER

https://addons.mozilla.org/en-US/firefox/addon/2691

A developer tool for interacting with web services and other web resources that lets you make HTTP requests, set the entity body, and content type. This allows you to interact with web services and inspect the results...

A: 

Are you trying to loop through all the posted values from the form? If so in ASP.OLD you could do this:

For Each Field in Request.Form

Jay
opensas
Not sure how it is passed in the "body" of the request...You have 2 methods of submitting data depending on whether the form type is a POST (hidden in the form variables) or a GET (through the URL). In general people use the POST method because of the length limitations and visibility of the GET. If you do not have variables in the URL/querystring then it should be coming through as a POST and you should be able to loop through the Request.Form fields to get the data.You can check which method you are using in the "method" parameter of the FORM element in your ASP web page.
Jay
you can post in the body using an ajax library (prototype for example)... ot test it I'm using a firefox plug-in, poster, that basically let you do a post with more options than available using a n html form, anyway, I guess I found how to do it, check my answer...
opensas
A: 

I think I found it

if you issue str( request.form ) you get the raw value of the form element...

works also with request.querystring and request.cookies

it doesn't work with request.serverVariables, throws an exception...

oh, and inspecting the debugger I've also found a completely undocumented property, request.body, that seems to behave just like the request.form property...

opensas
Body and Form both return an IRequestDictionary, I'm not sure how this helps you if your post is not a URL encoded form post?
AnthonyWJones
yeah, I know, that's why I was surprised too when I tried with cstr(request.form) and it gave me the whole thing... go ahead and try
opensas
+1  A: 

You didn't specify either what actual content type is being posted nor what you intented to do with it once you've acquired it.

Lets assume for a moment that the content is XML and you want to load it into an XML DOM.

A useful fact about the Request object is that it implements IStream where the stream is the entity body of the POST. Another useful fact is MSXML DOMDocument load method can accept an implementation of IStream. Hence:-

 Dim xml: Set xml = CreateObject("MSXML2.DOCDocument.3.0")
 xml.async = false
 xml.load Request

This code loads the posted entity body into the DOM.

AnthonyWJones
mmmm... that's an interesting option I wasn't aware of (by the way, where is this all thing documented, when googling around I just get the most basic samples...) I'll give it a try...
opensas
The official documentation for ASP objects is found here: http://msdn.microsoft.com/en-us/library/ms524716.aspx however the fact that Request implements IStream is nigh-on invisible.
AnthonyWJones