<div dir="ltr">How about just saying that the input is either the string "get" "put" "post" or a match pattern and if it is one of the former, then do case-folding before checking?<div><br></div>
<div>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jan 7, 2013 at 9:24 AM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay@racket-lang.org" target="_blank">jay@racket-lang.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I like the idea of the match patterns... but I'm worried about the details.<br>
<br>
The names are very common: get, post, head, etc. And I think exporting<br>
them as http-method-get or GET, etc would be hideous.<br>
<br>
Also, there is no exhaustive list of valid HTTP methods... anything<br>
can be used. And even the lisf of commonly used ones is long:<br>
<br>
<a href="http://annevankesteren.nl/2007/10/http-methods" target="_blank">http://annevankesteren.nl/2007/10/http-methods</a> (as of 2007)<br>
<br>
Do you have any ideas for a solution to this?<br>
<span class="HOEnZb"><font color="#888888"><br>
Jay<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Fri, Jan 4, 2013 at 9:27 AM, Sam Tobin-Hochstadt <<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>> wrote:<br>
> Ah, that makes sense. You could think about providing match patterns<br>
> for each of the HTTP methods, in that case -- people might be less<br>
> confused by that than strings.<br>
><br>
> On Fri, Jan 4, 2013 at 10:30 AM, Jay McCarthy <<a href="mailto:jay@racket-lang.org">jay@racket-lang.org</a>> wrote:<br>
>> The programmer's input is not a string. It is a match pattern, so you can<br>
>> use 'or', '_', etc.<br>
>><br>
>><br>
>> On Fri, Jan 4, 2013 at 6:30 AM, Sam Tobin-Hochstadt <<a href="mailto:samth@ccs.neu.edu">samth@ccs.neu.edu</a>><br>
>> wrote:<br>
>>><br>
>>> Why not normalize this at the other end (ie, normalize the provided<br>
>>> string as well as the actual method) so that "GET" as well as "get"<br>
>>> will work?<br>
>>><br>
>>> Sam<br>
>>><br>
>>> On Fri, Jan 4, 2013 at 7:45 AM, <<a href="mailto:jay@racket-lang.org">jay@racket-lang.org</a>> wrote:<br>
>>> > jay has updated `master' from aa5f2e7875 to c07ff948ee.<br>
>>> > <a href="http://git.racket-lang.org/plt/aa5f2e7875..c07ff948ee" target="_blank">http://git.racket-lang.org/plt/aa5f2e7875..c07ff948ee</a><br>
>>> ><br>
>>> > =====[ One Commit ]=====================================================<br>
>>> > Directory summary:<br>
>>> > 100.0% collects/web-server/scribblings/<br>
>>> ><br>
>>> > ~~~~~~~~~~<br>
>>> ><br>
>>> > c07ff94 Jay McCarthy <<a href="mailto:jay@racket-lang.org">jay@racket-lang.org</a>> 2013-01-04 05:44<br>
>>> > :<br>
>>> > | Fixes PR13406<br>
>>> > :<br>
>>> > M collects/web-server/scribblings/dispatch.scrbl | 11 +++++++++--<br>
>>> ><br>
>>> > =====[ Overall Diff ]===================================================<br>
>>> ><br>
>>> > collects/web-server/scribblings/dispatch.scrbl<br>
>>> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
>>> > --- OLD/collects/web-server/scribblings/dispatch.scrbl<br>
>>> > +++ NEW/collects/web-server/scribblings/dispatch.scrbl<br>
>>> > @@ -118,6 +118,7 @@ or else the filesystem server will never see the<br>
>>> > requests.<br>
>>> > [maybe-method<br>
>>> > code:blank<br>
>>> > (code:line #:method method)]<br>
>>> > + [method pat]<br>
>>> > [maybe-else-clause<br>
>>> > code:blank<br>
>>> > [else else-fun]])<br>
>>> > @@ -137,9 +138,15 @@ the @racket[dispatch-fun] given as its first<br>
>>> > argument.<br>
>>> > @racket[(next-dispatcher)] to signal to the Web Server that this<br>
>>> > dispatcher does not apply.<br>
>>> ><br>
>>> > - If any @racket[_method] is left out, it assumed to apply to requests<br>
>>> > -without methods and GET methods.<br>
>>> > + The @racket[_method] syntax is used in a @racket[match] expression to<br>
>>> > +match the @racket[request-method] part of the incoming request<br>
>>> > +object. However, since HTTP allows methods to use any case, the byte<br>
>>> > +string from @racket[request-method] is normalized to a lower-case<br>
>>> > +string. Thus, valid patterns are things like: @racket["get"],<br>
>>> > +@racket["post"], @racket["head"], @racket[(or "get" "post")], etc.<br>
>>> ><br>
>>> > + If @racket[_method] is left out, it assumed to apply to requests<br>
>>> > +without methods and GET methods.<br>
>>> > }<br>
>>> ><br>
>>> > @defform[<br>
>><br>
>><br>
_________________________<br>
Racket Developers list:<br>
<a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
</div></div></blockquote></div><br></div>