[racket] net/http-client

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Sep 17 10:18:42 EDT 2013

A new kind of dict seems like it would be able to deal with much of this.
For example, you could have a 'get' operation that would deal with the
multiple headers situation in a way that is likely to be what was intended
(whether that's an error or a 'get the last one' or some other operation)
and a get-multiple that would return the list (and have a longer name so
people wouldn't glom to it), similarly it could deal with lookups without
canonicalizing case ahead of time. You could have some kind of extensible
mechanism for dealing with parsing the right-hand sides of the table and
pre-populate it with the ones that are commonly cared about. Because of the
generics, this woudl "just work" when someone sticks it into a for loop, as
long as they are just doing something easy.

Robby


On Tue, Sep 17, 2013 at 8:51 AM, Jay McCarthy <jay.mccarthy at gmail.com>wrote:

> I think it's an obvious request, but a character flaw of mine is not
> doing things unless they can be done really good. In this case, I see
> a hash table as a "parse" of the headers. It's not obvious to me how
> to parse them. For example...
>
> - The same header can appear many times, so (Key -> Value) is
> incorrect, unless you overwrite one. It would be better to have (Key
> -> (Listof Value)) but that feels really ugly since most of the time
> there will just be one
> - The spec doesn't mandate case sensitivity on headers, so I would
> need to canonicalize "ACCept-ENCodiNG" to something else. Maybe
> 'Accept-Encoding?
> - The value of many headers is not really a string. For instance,
> Content-Length is a number, Cache-Control is an association list,
> Content-Disposition is complicated, etc. I feel like it is
> disingenuous to only partial parse.
> - Dealing with all this may be wasted effort for most requests that
> just care about the body
>
> For these reasons, I think http-client should just return the list of
> bytes. I think it would be nice to have another function that parses
> that so clients could optionally call it if it is important. That can
> be part of http-client.
>
> Jay
>
>
>
> On Tue, Sep 17, 2013 at 3:41 AM, adam moore <nerdfunk at gmail.com> wrote:
> > Hi Jay,
> >
> > Just looking over the new http client code - looking very nice, and
> > much better than my current slapped together parsing of
> > get-impure-port.
> >
> > I was wondering if it might be better to pass back the headers as
> > something easier to look up against, for example as a hash table? Or
> > perhaps, provide an option to do so. I think it's a pretty common use
> > case to provide for.
> >
> > Thanks again,
> > Adam
>
>
>
> --
> 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 Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130917/828c5756/attachment.html>

Posted on the users mailing list.