Folks,

I have just tried to HEAD a web server, and have come across a few
issues around the use of head-pure-port:

1. What is the point of `head-pure-port'? The HTTP server should not
   (must not?) send a body. Which means that once the port is purified,
   `head-pure-port' returns nothing. So it was a bit silly of me to
   expect anything in the first place (this is before I bumped into
   connection persistence); maybe the documentation could ask the
   potential user, "Didn't you really want to use `head-impure-port'?"

[So, in fact, I have issues with `head-impure-port']:

2. (port->string (head-impure-port
                  (string->url "http://www.bbc.co.uk/";)))
   takes way too long to potentially preflight a website.
   cpu time: 2578 real time: 29767 gc time: 125. This is due to
   HTTP keep-alive. For anyone who hits this, may I suggest two
   solutions:
    - keep-alive can be overridden with '("Connection: Close")
      passed as a header in `head-impure-port'
      (port->string (head-impure-port
                     (string->url "http://www.bbc.co.uk/";)
                     '("Connection: Close")))

    - if connection persistence is desirable (which I guess it usually
      is), then read the header until an empty line:
      (for/list ((p (in-port (curryr read-line 'return-linefeed)
                     (head-impure-port
                      (string->url "http://www.bbc.co.uk/";))))
                 #:break (string=? p ""))
       p)

3. Poking around url.rkt, I notice that `http-conn-impure-port' makes
   a pipe with a limit of 4096 bytes. http-client.rkt, which is directly
   required by url.rkt, defines (but does not provide) `PIPE-SIZE' --
   also 4096. Is there any merit in sharing this value between the
   files?

Tim

-- 
Tim Brown <t...@timb.net> ▪ +447771714159

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to