Erlang/OTP Forums

Author Message

<  Yaws mailing list  ~  Bug? 'PUT' method does not handle body content

Guest
Posted: Sun Sep 10, 2006 3:05 pm Reply with quote
Guest
I'm using Yaws to implement a REST API for a service (i.e. an appmod).
The API must accept data via the body of a 'PUT' method.

In yaws-1.64 (and in the current CVS tree), 'PUT' does not appear to
handle body content at all, although there is some apparently
incomplete code that hints at an intention to do so.

I'm new to yaws, but this seems like a clear bug to me, as compiling
yaws_server.erl gives the following warnings.

./yaws_server.erl:1220: Warning: variable 'PPS' is unused
./yaws_server.erl:1221: Warning: variable 'CT' is unused

The following patch seems to fix the problem for me. Please could
someone review/include it?

Many thanks,

Chris Newcombe

% diff -C 3 yaws_server.erl-before yaws_server.erl
*** yaws_server.erl-before 2006-09-10 07:53:18.000000000 -0700
--- yaws_server.erl 2006-09-10 07:54:04.000000000 -0700
***************
*** 1217,1230 ****
?format_record(Head, headers)]),
SC=get(sc),
ok = yaws:setopts(CliSock, [{packet, raw}, binary], is_ssl(SC#sconf.ssl)),
! PPS = SC#sconf.partial_post_size,
! CT =
! case yaws:lowercase(Head#headers.content_type) of
! "multipart/form-data"++_ -> multipart;
! _ -> urlencoded
! end,
! ARG = make_arg(CliSock, Head, Req, undefined),
! handle_request(CliSock, ARG, p).


'DELETE'(CliSock, Req, Head) ->
--- 1217,1223 ----
?format_record(Head, headers)]),
SC=get(sc),
ok = yaws:setopts(CliSock, [{packet, raw}, binary], is_ssl(SC#sconf.ssl)),
! body_method(CliSock, Req, Head).


'DELETE'(CliSock, Req, Head) ->

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist
Guest
Posted: Sun Sep 10, 2006 9:36 pm Reply with quote
Guest
Chris Newcombe wrote:
> I'm using Yaws to implement a REST API for a service (i.e. an appmod).
> The API must accept data via the body of a 'PUT' method.
>

ok


> In yaws-1.64 (and in the current CVS tree), 'PUT' does not appear to
> handle body content at all,


Well PUT isn't used, For a normal webserver PUT doesn't
make sense.

> The following patch seems to fix the problem for me. Please could
> someone review/include it?

The fix just removes the call to handle_request(). It also
breaks the almost working DAV implementation by Tobbe Tornquist and
Martin Bjorklund. DAV use both of the PUT and DELETE methods.



>
> % diff -C 3 yaws_server.erl-before yaws_server.erl
> *** yaws_server.erl-before 2006-09-10 07:53:18.000000000 -0700
> --- yaws_server.erl 2006-09-10 07:54:04.000000000 -0700
> ***************
> *** 1217,1230 ****
> ?format_record(Head, headers)]),
> SC=get(sc),
> ok = yaws:setopts(CliSock, [{packet, raw}, binary], is_ssl(SC#sconf.ssl)),
> ! PPS = SC#sconf.partial_post_size,
> ! CT =
> ! case yaws:lowercase(Head#headers.content_type) of
> ! "multipart/form-data"++_ -> multipart;
> ! _ -> urlencoded
> ! end,
> ! ARG = make_arg(CliSock, Head, Req, undefined),
> ! handle_request(CliSock, ARG, p).
>
>
> 'DELETE'(CliSock, Req, Head) ->
> --- 1217,1223 ----
> ?format_record(Head, headers)]),
> SC=get(sc),
> ok = yaws:setopts(CliSock, [{packet, raw}, binary], is_ssl(SC#sconf.ssl)),
> ! body_method(CliSock, Req, Head).
>
>
> 'DELETE'(CliSock, Req, Head) ->


So sorry, can't take it. A proper fix has to do more.....



/klacke

--
Claes Wikstrom -- Caps lock is nowhere and
http://www.tail-f.com -- everything is under control
cellphone: +46 70 2097763

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum