Thanks for the reply. See below for the server code I'm using.<div><br></div><div>I narrowed down the problem a bit and there are actually two different but related issues. The first is that request data is ignored for non-POST, non-PUT requests:</div>
<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">$ curl <a href="http://localhost:8000">http://localhost:8000</a> -d "abcd" -X POST</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><html><p><b>POST</b></p><p><b>abcd</b></p></html></font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">$ curl <a href="http://localhost:8000">http://localhost:8000</a> -d "abcd" -X PATCH</font><div style="font-family: 'courier new', monospace; ">
<html><p><b>PATCH</b></p><p><b>No request body</b></p></html></div><div style="font-family: 'courier new', monospace; "><br></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">The second problem is that POST and PUT requests hang when no request body is specified:</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">$ curl <a href="http://localhost:8000">http://localhost:8000</a> -X POST (hangs)</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">$ curl <a href="http://localhost:8000">http://localhost:8000</a> -X PUT (hangs)</span></font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">No server errors, even after killing the request. I imagine the server is waiting on the request stream to parse a request body that will never come.</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">Daniel</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br>
</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">---</font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">And here's the server code:</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><div><font class="Apple-style-span" face="'courier new', monospace">#lang racket</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br>
</font></div><div><font class="Apple-style-span" face="'courier new', monospace">(require web-server/servlet-env</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> web-server/http/xexpr</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> web-server/http/request-structs</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> web-server/dispatch)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">(define-values (app-dispatch app-url)</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace"> (dispatch-rules</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> [("") index]</font></div><div>
<font class="Apple-style-span" face="'courier new', monospace"> [else index]))</font></div><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">(define (index req)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> (response/xexpr `(html (p ,(bytes->string/utf-8 (request-method req)))</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> (p ,(cond ((bytes? (request-post-data/raw req))</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> (bytes->string/utf-8 (request-post-data/raw req)))</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> (else "No request body"))))))</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font class="Apple-style-span" face="'courier new', monospace">(serve/servlet app-dispatch</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> #:port 8000</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> #:servlet-regexp #rx""</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> #:command-line? #t)</font></div>
<br><div class="gmail_quote">On Mon, Sep 12, 2011 at 5:50 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;">
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>
<div><div></div><div class="h5"><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 defined<br>
> a dispatch function for, the request hangs indefinitely. The docs say that<br>
> the web server tries to hide the details of the request method from you. Is<br>
> there any way to work around this? Or am I limited to defining GET requests<br>
> with continuations?<br>
> Thanks,<br>
> Daniel<br>
</div></div>> _________________________________________________<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>
<font color="#888888"><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>
</font></blockquote></div><br></div></div>