Yaws / Post arguments

Ingela Anderton <>
Tue Aug 16 17:12:16 CEST 2005


No you are not doing anything silly. I am afraid that is bug.
I will fix it. If you want it to work right away
you should patch the function post_data in the file httpc_request.erl
to look like.

post_data(Method, Headers, {ContentType, Body}) 
  when Method == post; Method == put ->
    ContentLength = body_length(Body),	      
    NewBody = case Headers#http_request_h.expect of
		  "100-continue" ->
		      "";
		  _ ->
		      Body
	      end,
    {Headers#http_request_h{'content-type' = ContentType, 
			    'content-length' = ContentLength},
     NewBody};

And add this function to the same module.
body_length(Body) when is_binary(Body) ->
   integer_to_list(size(Body)).

body_length(Body) when is_list(Body) ->
  integer_to_list(length(Body)).

Dale Harvey wrote:
> Heh the . was a mistype, 
> 
> Didnt notice the type definitions last time i looked, thanks, still
> getting troubles though
> 
> Bleh = #Record{define="stuff"},
> http:request(post,{"http://blehbleh", [] , "text/plain",
> term_to_binary(Bleh)}, [] , []).
> 
> and 
> 
> http:request(post,{"http://blehbleh", [] , "text/plain",
> term_to_binary({123,"bleh"})}, [] , []).
> 
> are both still crashing on me, theres hundreds of lines getting thrown
> out but the error seems to be down to
> badmatch,(error,(badarg,[{erlang,length,[<<thebinaryreturnedfromtermtobinary>>]}
> 
> its definetaly a valid binary type im sending, binary_to_term comes
> out fine, just playing around i tried
> 
> http:request(post,{"http://blehbleh", [] , "text/plain",
> [term_to_binary({123,"bleh"})]}, [] , []).
> 
> which doesnt crash but the arguements unsuprisingly dont come out the
> other end right
> 
> sending a valid binary type should according to the user guide work
> fine, am i doing something silly?

-- 
/Ingela - OTP team








More information about the erlang-questions mailing list