[plt-scheme] Module servlets and non-sexpr responses

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Sun Nov 19 13:28:51 EST 2006

I just remember that if I put "image/gif" instead of #"image/gif", everything does't work.

So, the document says both string and bytes-string can be used, but actually only bytes-string works. Please try #"text/html".

Chongkai

----- Original Message ----- 
From: "Chongkai Zhu" <czhu at cs.utah.edu>
To: "Jens Axel Søgaard" <jensaxel at soegaard.net>; "PLT-list" <plt-scheme at list.cs.brown.edu>
Sent: Sunday, November 19, 2006 11:24 AM
Subject: Re: [plt-scheme] Module servlets and non-sexpr responses


> I'm not sure what's wrong with your code, but in my program, I use unit servlets, and 
> the following codes work fine:
> 
> (make-response/full 200 "OK" (current-seconds) #"text/plain" () (list s)))
> 
> (make-response/full 200 "OK"
>                                                       (current-seconds)
>                                                       #"image/gif"
>                                                       ()
>                                                       (list (string->bytes/latin-1 s)))
> 
> where s is a string (the content of a file). Hope this can help you.
> 
> Chongkai
> 
> ----- Original Message ----- 
> From: "Jens Axel Søgaard" <jensaxel at soegaard.net>
> To: "PLT-list" <plt-scheme at list.cs.brown.edu>
> Sent: Sunday, November 19, 2006 10:22 AM
> Subject: [plt-scheme] Module servlets and non-sexpr responses
> 
> 
>> According to
>> 
>> <http://pre.plt-scheme.org/docs/html/web-server/web-server-Z-H-12.html#node_sec_10.1.3>
>> 
>> a legal response from a servlets is
>> 
>>   (listof (union string bytes))
>>       The first string is the MIME type (often "text/html", but see RFC
>>    2822 for other options). The rest of the strings provide the
>>    document's content.
>> 
>> but nevertheless, I can't get this simple example to run:
>> 
>> (module static mzscheme
>>   (require (lib "servlet.ss" "web-server"))
>>   (provide interface-version timeout start)
>>   (define interface-version 'v1)
>>   (define timeout +inf.0)
>>   (define (start initial-request)
>>      (report-errors-to-browser send/finish)
>>       (list
>>        "text/html"
>>        "<html><head></head><body>Foo</body><html>")))
>> 
>> I get the following error in the browser:
>> 
>> <html>
>>   <head><title>Erroneous Xexpr</title></head>
>>   <body><h1>Erroneous Xexpr</h1>
>>   <p>An Xexpr in the servlet is malformed. The exact error
>> is</p>
>> 
>> <pre>Expected a symbol as the element name, given
>> text/html</pre>
>> 
>> <h2>The Full Xexpr Is</h2>
>> 
>> <pre><font color="red">
>>   ("text/html" "<html><head></head><body>Foo</body></html>")
>> </font></pre>
>> 
>> Am I misinterpreting the documentation?
>> 
>> -- 
>> Jens Axel Søgaard
>> 
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>

Posted on the users mailing list.