[racket] HTTP-POST byte string gets truncated

From: Mikko Tiihonen (mikko.tiihonen at tmtiihonen.fi)
Date: Mon Oct 8 03:07:28 EDT 2012

Hi, Danny,

the header is here:

(define header (list (insert-field #"Host" #"localhost:8080"
                                 (insert-field #"Connection" #"keep-alive"
                                               (insert-field #"User-Agent" #"Mozilla/5.0 (testClient.rkt 0.1)"
                                                             (insert-field #"Accept-Encoding" #"gzip"
                                                                           (insert-field #"Accept" #"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
                                                                                         (insert-field #"Accept-Language" #"en-us"
                                                                                                       (insert-field #"Accept-Charset" #"ISO-8859-1,UTF-8;q=0.7,*;q=0.7"
                                                                                                                     (insert-field #"Cache-control" #"no-cache" empty-header))))))))))
For some reason the request struct on the server side seems to get the POST data four bytes off... I also noticed that empty-header does not evaluate to "\r\n\r\n" as specified in net/head documentation:
> empty-header

validate-header validates the header as one string, but post-pure-port requires that the header is contained in a list of strings ("optional list of strings can be used to send header lines to the server"). Is there some kind of a mismatch between net/url and net/head?



On 8.10.2012, at 2:49, Danny Yoo wrote:

> On Sat, Oct 6, 2012 at 4:50 AM, Mikko Tiihonen
> <mikko.tiihonen at tmtiihonen.fi> wrote:
>> Hi, again!
>> I'm continuing to build a small HTTP-client. The problem is now that the POST parameter/value byte strings sent by put-pure-port and post-pure-port seem to get truncated somewhere. The request-post-data/raw shows that the byte string gets prepended with "\r\n\r\n" and truncated by four bytes. E.g.
>> (post-pure-port uri #"param1=hello&param2=world" header)
>> is received as
>> #"\r\n\r\nparam1=hello&param2=w"
> Odd.  What's the content of 'header' here?  It's the only free
> variable I see whose value I don't quite understand yet.

Posted on the users mailing list.