Yaws / Post arguments
Ingela Anderton
ingela@REDACTED
Tue Aug 16 09:23:15 CEST 2005
Dale Harvey wrote:
> Hey
>
> Im having problems building post arguments to send with the the http modules
>
> I was hoping to be able to chuck a record like so
>
> Bleh = #Record{define="stuff"},
> http:request(post,{"http://blehbleh", [] , "text/plain",Bleh}. [] , []).
>
> and have the erlang client sort the headers out nicely, but
> httpc_manager keeps shouting at me for that.
The inets HTTP-Client API states that a request could be:
request() - {url(), headers()} |
{url(), headers(), content_type(), body()}
where body is:
body() = string() | binary()
So in your case that would be:
Bleh = #Record{define="stuff"},
http:request(post,{"http://blehbleh", [] ,
"text/plain", term_to_binary(Bleh)}, [] , []).
^^^
note not "." but ","
> So ive been trying to just make the format the post arguments myself,
> My first guess was a list of key value tuples, since thats how they
> come out of parse_post
>
> http:request(post,{"http://blehbleh", [] , "text/plain",
> [{"key1",Val1},{"key2",Val2}] }. [] , []).
As noted above: On the client side the post body should be of type
string() or binary().
> but that gives a similiar error, ive tried most combinations of
> tuples, lists all with the same error. I couldnt find any records in
> the yaw_api pertaining to this, and no docs suggesting how to arrange
> the post arguments
>
> right now
>
> http:request(post,{"http://blehbleh", [] , "text/plain", "key1" }. [] , []).
>
> gives me [("key1",undefined}] from yaws_api:parse_post
>
> but no luck on adding a value, or extra vars
How yaws works I will leave to Clacke to explain ;)
--
/Ingela - OTP team
More information about the erlang-questions
mailing list