[racket] net/http-client

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Tue Sep 17 09:51:12 EDT 2013

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

Posted on the users mailing list.