<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks, Greg and Danny!<div><br></div><div>Problem solved - now the POST parameters are also correct! Seems that the different representation of headers in net/head caused the POST parameters following the header being parsed incorrectly.</div><div><br></div><div>Cheers,</div><div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>-Mikko</div></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On 8.10.2012, at 14:52, Greg Hendershott wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><blockquote type="cite">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?<br></blockquote><br>Yes, unfortunately they represent headers differently. net/head<br>represents headers as a single "string" or #"bytes string" consisting<br>of \r\n separated elements. This is closest to the headers in real<br>life. However net/url uses a list of elements (and they're "string"<br>elements only; not #"byte string").<br><br>Since you're using post-pure-port from net/url, I think you want:<br><br>(define header<br> (list "Host: localhost:8080"<br> "Connection: keep-alive"<br> "User-Agent: Mozilla/5.0 (testClient.rkt 0.1)"<br> "Accept-Encoding: gzip"<br> "Accept:<br>text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"<br> "Accept-Language: en-us"<br> "Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7"<br> "Cache-control: no-cache"))<br>(post-pure-port my-url my-data header)<br><br><br>On Mon, Oct 8, 2012 at 3:07 AM, Mikko Tiihonen<br><<a href="mailto:mikko.tiihonen@tmtiihonen.fi">mikko.tiihonen@tmtiihonen.fi</a>> wrote:<br><blockquote type="cite">Hi, Danny,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">the header is here:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">(define header (list (insert-field #"Host" #"localhost:8080"<br></blockquote><blockquote type="cite"> (insert-field #"Connection" #"keep-alive"<br></blockquote><blockquote type="cite"> (insert-field #"User-Agent" #"Mozilla/5.0 (testClient.rkt 0.1)"<br></blockquote><blockquote type="cite"> (insert-field #"Accept-Encoding" #"gzip"<br></blockquote><blockquote type="cite"> (insert-field #"Accept" #"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"<br></blockquote><blockquote type="cite"> (insert-field #"Accept-Language" #"en-us"<br></blockquote><blockquote type="cite"> (insert-field #"Accept-Charset" #"ISO-8859-1,UTF-8;q=0.7,*;q=0.7"<br></blockquote><blockquote type="cite"> (insert-field #"Cache-control" #"no-cache" empty-header))))))))))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">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:<br></blockquote><blockquote type="cite"><blockquote type="cite">empty-header<br></blockquote></blockquote><blockquote type="cite">"\r\n"<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">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?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Cheers,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">-Mikko<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On 8.10.2012, at 2:49, Danny Yoo wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">On Sat, Oct 6, 2012 at 4:50 AM, Mikko Tiihonen<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><<a href="mailto:mikko.tiihonen@tmtiihonen.fi">mikko.tiihonen@tmtiihonen.fi</a>> wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Hi, again!<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">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.<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">(post-pure-port uri #"param1=hello&param2=world" header)<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">is received as<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">#"\r\n\r\nparam1=hello&param2=w"<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Odd. What's the content of 'header' here? It's the only free<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">variable I see whose value I don't quite understand yet.<br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">____________________<br></blockquote><blockquote type="cite"> Racket Users list:<br></blockquote><blockquote type="cite"> <a href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a><br></blockquote></div></blockquote></div><br></div></body></html>