Works great. Thanks!<div><br>Daniel<br><br><div class="gmail_quote">On Tue, Sep 13, 2011 at 7:58 AM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I just pushed a fix to these issues.<br>
<br>
Problem 1 was that I only read request bodies on POSTs.<br>
<br>
Problem 2 was that I misread the spec and didn't see that request<br>
bodies had to have Content-Length fields.<br>
<br>
Jay<br>
<br>
On Mon, Sep 12, 2011 at 12:29 PM, Daniel MacDougall<br>
<div><div></div><div class="h5"><<a href="mailto:dmacdougall@gmail.com">dmacdougall@gmail.com</a>> wrote:<br>
> Thanks for the reply. See below for the server code I'm using.<br>
> I narrowed down the problem a bit and there are actually two different but<br>
> related issues. The first is that request data is ignored for non-POST,<br>
> non-PUT requests:<br>
> $ curl <a href="http://localhost:8000" target="_blank">http://localhost:8000</a> -d "abcd" -X POST<br>
> <html><p>POST</p><p>abcd</p></html><br>
> $ curl <a href="http://localhost:8000" target="_blank">http://localhost:8000</a> -d "abcd" -X PATCH<br>
> <html><p>PATCH</p><p>No request body</p></html><br>
> The second problem is that POST and PUT requests hang when no request body<br>
> is specified:<br>
> $ curl <a href="http://localhost:8000" target="_blank">http://localhost:8000</a> -X POST (hangs)<br>
> $ curl <a href="http://localhost:8000" target="_blank">http://localhost:8000</a> -X PUT (hangs)<br>
> No server errors, even after killing the request. I imagine the server is<br>
> waiting on the request stream to parse a request body that will never come.<br>
> Daniel<br>
> ---<br>
> And here's the server code:<br>
> #lang racket<br>
> (require web-server/servlet-env<br>
> web-server/http/xexpr<br>
> web-server/http/request-structs<br>
> web-server/dispatch)<br>
> (define-values (app-dispatch app-url)<br>
> (dispatch-rules<br>
> [("") index]<br>
> [else index]))<br>
> (define (index req)<br>
> (response/xexpr `(html (p ,(bytes->string/utf-8 (request-method req)))<br>
> (p ,(cond ((bytes? (request-post-data/raw req))<br>
> (bytes->string/utf-8<br>
> (request-post-data/raw req)))<br>
> (else "No request body"))))))<br>
> (serve/servlet app-dispatch<br>
> #:port 8000<br>
> #:servlet-regexp #rx""<br>
> #:command-line? #t)<br>
> On Mon, Sep 12, 2011 at 5:50 AM, Jay McCarthy <<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>><br>
> wrote:<br>
>><br>
>> This sounds strange to me. Request objects have a 'method' field that<br>
>> you can look at it. The bindings are a promise so that non-form-data<br>
>> POST content doesn't get erroneously parsed as bindings (unless you<br>
>> force the promise). This is all in place so that you can implement<br>
>> which ever methods you want without interference from the server's<br>
>> default behavior. Can you post a small example that has the hanging<br>
>> error?<br>
>><br>
>> Jay<br>
>><br>
>> On Sat, Sep 10, 2011 at 8:12 PM, Daniel MacDougall<br>
>> <<a href="mailto:dmacdougall@gmail.com">dmacdougall@gmail.com</a>> wrote:<br>
>> > Hi,<br>
>> > I'm trying to build a web server that responds to [POST/PUT/DELETE]<br>
>> > requests. If I use the built-in web server and POST to a url I have<br>
>> > defined<br>
>> > a dispatch function for, the request hangs indefinitely. The docs say<br>
>> > that<br>
>> > the web server tries to hide the details of the request method from you.<br>
>> > Is<br>
>> > there any way to work around this? Or am I limited to defining GET<br>
>> > requests<br>
>> > with continuations?<br>
>> > Thanks,<br>
>> > Daniel<br>
>> > _________________________________________________<br>
>> > For list-related administrative tasks:<br>
>> > <a href="http://lists.racket-lang.org/listinfo/users" target="_blank">http://lists.racket-lang.org/listinfo/users</a><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
>> Assistant Professor / Brigham Young University<br>
>> <a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
>><br>
>> "The glory of God is Intelligence" - D&C 93<br>
><br>
><br>
<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class="h5">Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
Assistant Professor / Brigham Young University<br>
<a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>
"The glory of God is Intelligence" - D&C 93<br>
</div></div></blockquote></div><br></div>