[racket] #:headers not working with dispatch

From: Guillaume Coré (g at fridim.org)
Date: Tue Nov 19 11:24:14 EST 2013

Hi Jay,

Thank you for the explanation.

Guillaume

On 11/19/2013 10:35 AM, Jay McCarthy wrote:
> Hi Guillaume,
> 
> Your code works exactly as expected, but you are not testing it properly.
> 
> "curl -I" sends a HEAD request, but your dispatch case only responds
> to GET requests, because you have left out "#:method" and are using
> the default as documented here:
> 
> http://docs.racket-lang.org/web-server/dispatch.html?q=dispatch-case#(form._((lib._web-server/dispatch..rkt)._dispatch-rules))
> 
> in the last paragraph.
> 
> If you run with "curl -v" then you'll send a GET request and see the
> headers you expect
> 
> Jay
> 
> 
> 
> On Sun, Nov 17, 2013 at 9:37 AM, Guillaume Coré <g at fridim.org> wrote:
>> Hi,
>>
>> Here is a simple case where #:headers works (working.rkt attached)
>>
>> Now the same thing but using dispatch (not_working.rkt attached) does
>> not return the header. I'm a bit lost here.
>>
>>
>> I was told on IRC to try to compare the return values of both (start)
>> with/without dispatch. I did but both seems to return the expected header :
>>
>> (define (start request)
>>   (response/xexpr (index request)
>>                   #:headers (list (make-header #"Cache-Control"
>> #"max-age=0"))))
>>
>> (define (start2 request)
>>   (response/xexpr (site-dispatch request)
>>                   #:headers (list (make-header #"Cache-Control"
>> #"max-age=0"))))
>>
>>
>> (define (url->request u)
>>     (make-request #"GET" (string->url u) empty
>>                   (delay empty) #f "1.2.3.4" 80 "4.3.2.1"))
>>
>> (response-headers (start (url->request "http://localhost:8000/")))
>> ;-> '(#(struct:header #"Cache-Control" #"max-age=0"))
>> (response-headers (start2 (url->request "http://localhost:8000/")))
>> ;-> '(#(struct:header #"Cache-Control" #"max-age=0"))
>>
>> I'm using v5.90.0.10
>>
>> Any idea ?
>>
>> Regards,
>> Guillaume
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
> 
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20131119/b3ee1667/attachment.sig>

Posted on the users mailing list.