Erlang/OTP Forums

Author Message

<  Yaws mailing list  ~  Problem with page directive during POST request

Guest
Posted: Tue May 06, 2008 9:41 am Reply with quote
Guest
Hi,

I'm been having a problem using the yaws {page, <url>} directive in
conjunction with a browser POST request, which looks to me like a bug
in the server. I've attached a simple example to illustrate the
problem. The tar.gz file contains three files:

index.yaws
page_post.yaws
page_post_display.yaws

The index.yaws has two simple forms that each take a text field and
call page_post.yaws, one via a GET request and one via POST. The
page_post.yaws acts like a very simple controller which sets a binding
variable "Text" with a value from the text field, and then uses a
"page" directive to redirect to page_post_display.yaws, which displays
the variable.

All this works fine if you use a GET request but if you use POST the
browser seems to hang and the display page never appears.

Having looked at things in a bit more depth, I believe I know what is
going on. When yaws receives a "page" directive, it starts another
request response cycle with the original request data modified with
the URL of the requested page, essentially "pretending" that the
original request came from that page. However, if that request is a
POST request, it seems that it tries to read the POST data for a
second time from the browser. That data isn't there to read, so the
server hangs in IP receive before eventually timing out.

I've attached a patch to yaws_server.erl that seems to sort the
problem out for me. It sets the content_length field of the header to
undefined when handling a "page" directive, which stops the reading of
data. I'm not completely sure if this is right; looking at the start
of yaws_server:body_method if the headers.transfer_encoding was
"chunked" things look on the face of things like they would go
horribly wrong. I don't know enough about the internals of the server
to know if this could happen. Maybe it would be a better approach to
convert the request to look like a GET.

Thoughts anyone?

Rob David


Post received from mailinglist
Guest
Posted: Wed May 07, 2008 10:42 am Reply with quote
Guest
Robert David wrote:
> Hi,
>
> I'm been having a problem using the yaws {page, <url>} directive in
> conjunction with a browser POST request, which looks to me like a bug

Patch looks good - thanks, applied.

/klacke

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post received 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