[racket-dev] net/url - get-pure-port/headers

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Aug 2 09:35:25 EDT 2012

I have written code with get-pure-port/headers and I would very much like to get the status line. Not an external opinion though. 


On Aug 2, 2012, at 8:54 AM, Jay McCarthy wrote:

> The documentation of get-pure-port/headers seems to suggest that it
> returns the same thing
> 
> (call/input-url u
> (lambda (p)
>  (define hs (purify-port p))
>  (values p hs)))
> 
> would, except that it also handles redirections
> 
> However, it does not actually give the value returned by
> purify-port---it deletes the first line (the status line).
> 
> This means that a caller get-pure-port/headers can't tell the status
> code returned by the server they've contacted and they may consider
> the descriptive body of a 404 message as the data they want.
> 
> There's only one use of get-pure-port/headers in the core and it is
> robust against adding this line back in. (It uses net/head, which does
> not assume its input is only header lines, but uses regexps to find
> the header. So if any line is not a valid header line, then it works
> fine.) My guess is that most code also does that, so this change would
> be unlikely to break things in the wild. (Although there are no uses
> on Planet, so I can't tell.)
> 
> An alternative is to change the contract for get-pure-port/headers to
> return three values rather than two, but I think that is more likely
> to break external code.
> 
> Can I get a second opinion?
> 
> Jay
> 
> -- 
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://faculty.cs.byu.edu/~jay
> 
> "The glory of God is Intelligence" - D&C 93
> _________________________
>  Racket Developers list:
>  http://lists.racket-lang.org/dev

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4373 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20120802/37e124a0/attachment.p7s>

Posted on the dev mailing list.