<div dir="ltr">Valid. I guess I shouldn't pin too much faith on something that introduces itself in the comments as a "wanna be library."<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 24, 2013 at 12:13 PM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay.mccarthy@gmail.com" target="_blank">jay.mccarthy@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Tue, Sep 24, 2013 at 12:31 PM, Evan Donahue <<a href="mailto:emdonahu@gmail.com">emdonahu@gmail.com</a>> wrote:<br>
> Hmm, I'm no expert on http cookies, but here are the sticking points (or<br>
> possibly misinterpretations of the spec and/or the library) that have been<br>
> holding me up (referencing rfc2965):<br>
><br>
> 1) the print-cookie function generates path, domain, comment, etc fields<br>
> that don't belong in a Cookie header, so to use print-cookie the cookie must<br>
> only contain name and value (and no alternative print can be written due to<br>
> lack of accessors).<br>
><br>
> 2) Since the domain/path etc cannot be accessed, this information would have<br>
> to be stored in whatever container was holding your set of cookies for<br>
> selecting the appropriate cookies to send (an interface you note should<br>
> probably be better supported).<br>
><br>
> 3) Even with accessors, the domain mutator validates the domain as requiring<br>
> a leading '.' which, if no domain is specified, I believe bars the cookies<br>
> from holding the default value of the fully qualified host.<br>
><br>
> Also, one question: what do you mean by "There's no plans to add this, but<br>
> it should be very easy to anyone that has a use to expose the right stuff<br>
> from net/cookie." ?<br>
<br>
</div>I mean<br>
<br>
1. I have no plans to change net/cookie.<br>
<br>
2. net/cookie is really simple, so if you feel like you know anything<br>
about cookies, you should be able to change it and make it do what you<br>
want. (Or actually, I'd be surprised if it does anything well enough<br>
that you'd want to keep any of it when making a new interface that<br>
works better for the client, if you felt like the client interface<br>
were not good.)<br>
<span class="HOEnZb"><font color="#888888"><br>
Jay<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> Thanks,<br>
> Evan<br>
><br>
><br>
> On Tue, Sep 24, 2013 at 5:33 AM, Jay McCarthy <<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>><br>
> wrote:<br>
>><br>
>> I believe the net/cookie was intended to be used for both client and<br>
>> server. For instance, print-cookie turns a cookie structure into a<br>
>> string, which is a header that can be used on either side. I think the<br>
>> only thing that would be needed as far as structure accessors would be<br>
>> a way to find the cookies for a given path from a collection of<br>
>> cookies. There's no plans to add this, but it should be very easy to<br>
>> anyone that has a use to expose the right stuff from net/cookie.<br>
>><br>
>> I do think net/cookie is ripe to be improved though. I think something<br>
>> more like web-server/http/cookie would be better than the interface it<br>
>> provides.<br>
>><br>
>> Jay<br>
>><br>
>><br>
>> On Mon, Sep 23, 2013 at 8:21 PM, Evan Donahue <<a href="mailto:emdonahu@gmail.com">emdonahu@gmail.com</a>> wrote:<br>
>> > As long as people are discussing http client libraries, I've been<br>
>> > wondering<br>
>> > what the status of net/cookie is. It seems that it's geared towards<br>
>> > server-side cookie management (and I don't see an obvious way to<br>
>> > generate<br>
>> > Cookie: headers from net/cookie structs since none of the accessors are<br>
>> > exported). Is there an existing or planned cannonical solution to<br>
>> > managing<br>
>> > cookies on the client side?<br>
>> ><br>
>> > Thanks,<br>
>> > Evan<br>
>> ><br>
>> ><br>
>> > On Thu, Sep 19, 2013 at 11:21 AM, Erik Pearson <<a href="mailto:erik@adaptations.com">erik@adaptations.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> Just finishing up a two day wrestling match with net/url, couchdb, and<br>
>> >> assorted other incomplete libraries ... I have some fresh insight.<br>
>> >><br>
>> >> First, the new http client library will be very welcome!<br>
>> >><br>
>> >> A quick review of the existing code relieves me of most of my worries<br>
>> >> about net/url, which is a bit of a beautiful mess. In particular, I<br>
>> >> think<br>
>> >> that some of the code that analyzes the header is too brittle. In<br>
>> >> net/url a<br>
>> >> header is expected to be nearly perfectly formed. For instance, the<br>
>> >> "chunked" condition is tested for by a match against the literal header<br>
>> >> string "Transfer-Encoding: chunked". Just a difference in case, or an<br>
>> >> extra<br>
>> >> space somewhere will lead to a false negative. In the new code, this is<br>
>> >> done<br>
>> >> by a much more forgiving regexp comparison. However, I'm not sure this<br>
>> >> goes<br>
>> >> far enough. More on that in a sec.<br>
>> >><br>
>> >> I would like to make some recommendations:<br>
>> >> - keep text as bytstrings -- it looks like this is the way the new<br>
>> >> library<br>
>> >> works (but not net/url.)<br>
>> >> - the status line should be parsed and the status code converted to an<br>
>> >> integer.<br>
>> >> - The header should be parsed into the simplest usable form. I would<br>
>> >> suggest that an alist, with the key being a lower cased symbol and the<br>
>> >> value<br>
>> >> being the original bytestring.<br>
>> >> - When forming a header for a request, the same format should be used.<br>
>> >> I<br>
>> >> realize that if one wants proper-cased field names, the library will<br>
>> >> need to<br>
>> >> perform this formatting.<br>
>> >> - All information should be made available back to the api user.<br>
>> >> - Standard header field values should be optionally parsed<br>
>> >><br>
>> >> These changes would make the library much more useful. It would be<br>
>> >> consistent with http library design across languages. It would also<br>
>> >> promote<br>
>> >> more uniformity across Racket libraries which use them. I've found that<br>
>> >> when<br>
>> >> diving into a library (currently I'm dealing with couchdb) that has to<br>
>> >> reinvent the http wheel -- it may be reinvented with a slight twist. If<br>
>> >> one<br>
>> >> is using multiple libraries together, each with a different idea of<br>
>> >> what a<br>
>> >> header or https status line is, well, things get really unnecessarily<br>
>> >> complicated.<br>
>> >><br>
>> >> I think the core library could benefit from this as well. For instance,<br>
>> >> when looking for fields in the header, it would be more reliable to<br>
>> >> find the<br>
>> >> field in an alist, than to use an regex to extract values out of the<br>
>> >> bytestring. This is a very common operation when dealing with http, and<br>
>> >> I<br>
>> >> think it should be as simple and reliable as practical.<br>
>> >><br>
>> >> Finally I would recommend that there be a facility for decoding and<br>
>> >> encoding standard header fields. The application of the parsing would<br>
>> >> be<br>
>> >> optional, but I think it is important to have an implementation in the<br>
>> >> core<br>
>> >> library. The header field names and formats are well specified, and<br>
>> >> there<br>
>> >> are not all that many of them. They could be supplied as a hash or<br>
>> >> aref,<br>
>> >> with the field name lower-cased symbol (as in the parsed header) as key<br>
>> >> and<br>
>> >> two functions, one to decode from a bytstring, and one to encode into a<br>
>> >> bytestring. The simplest, most racketiest data structure would be best.<br>
>> >> A<br>
>> >> library user could grab this translation database and extend or modify<br>
>> >> it at<br>
>> >> will, but they would have a great head start.<br>
>> >><br>
>> >> Anyway, this is far from exhaustive, but these are some of the issues<br>
>> >> I've<br>
>> >> grappled with in recent hours and are right on the top of my head.<br>
>> >><br>
>> >><br>
>> >> On Tue, Sep 17, 2013 at 6:51 AM, Jay McCarthy <<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>><br>
>> >> wrote:<br>
>> >>><br>
>> >>> I think it's an obvious request, but a character flaw of mine is not<br>
>> >>> doing things unless they can be done really good. In this case, I see<br>
>> >>> a hash table as a "parse" of the headers. It's not obvious to me how<br>
>> >>> to parse them. For example...<br>
>> >>><br>
>> >>> - The same header can appear many times, so (Key -> Value) is<br>
>> >>> incorrect, unless you overwrite one. It would be better to have (Key<br>
>> >>> -> (Listof Value)) but that feels really ugly since most of the time<br>
>> >>> there will just be one<br>
>> >>> - The spec doesn't mandate case sensitivity on headers, so I would<br>
>> >>> need to canonicalize "ACCept-ENCodiNG" to something else. Maybe<br>
>> >>> 'Accept-Encoding?<br>
>> >>> - The value of many headers is not really a string. For instance,<br>
>> >>> Content-Length is a number, Cache-Control is an association list,<br>
>> >>> Content-Disposition is complicated, etc. I feel like it is<br>
>> >>> disingenuous to only partial parse.<br>
>> >>> - Dealing with all this may be wasted effort for most requests that<br>
>> >>> just care about the body<br>
>> >>><br>
>> >>> For these reasons, I think http-client should just return the list of<br>
>> >>> bytes. I think it would be nice to have another function that parses<br>
>> >>> that so clients could optionally call it if it is important. That can<br>
>> >>> be part of http-client.<br>
>> >>><br>
>> >>> Jay<br>
>> >>><br>
>> >>><br>
>> >>><br>
>> >>> On Tue, Sep 17, 2013 at 3:41 AM, adam moore <<a href="mailto:nerdfunk@gmail.com">nerdfunk@gmail.com</a>><br>
>> >>> wrote:<br>
>> >>> > Hi Jay,<br>
>> >>> ><br>
>> >>> > Just looking over the new http client code - looking very nice, and<br>
>> >>> > much better than my current slapped together parsing of<br>
>> >>> > get-impure-port.<br>
>> >>> ><br>
>> >>> > I was wondering if it might be better to pass back the headers as<br>
>> >>> > something easier to look up against, for example as a hash table? Or<br>
>> >>> > perhaps, provide an option to do so. I think it's a pretty common<br>
>> >>> > use<br>
>> >>> > case to provide for.<br>
>> >>> ><br>
>> >>> > Thanks again,<br>
>> >>> > Adam<br>
>> >>><br>
>> >>><br>
>> >>><br>
>> >>> --<br>
>> >>> Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
>> >>> Assistant Professor / Brigham Young University<br>
>> >>> <a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
>> >>><br>
>> >>> "The glory of God is Intelligence" - D&C 93<br>
>> >>> ____________________<br>
>> >>> Racket Users list:<br>
>> >>> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>> >><br>
>> >><br>
>> >><br>
>> >><br>
>> >> --<br>
>> >> Erik Pearson<br>
>> >> Adaptations<br>
>> >> ;; web form and function<br>
>> >><br>
>> >> ____________________<br>
>> >> Racket Users list:<br>
>> >> <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
>> >><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
>> Assistant Professor / Brigham Young University<br>
>> <a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
>><br>
>> "The glory of God is Intelligence" - D&C 93<br>
><br>
><br>
<br>
<br>
<br>
--<br>
Jay McCarthy <<a href="mailto:jay@cs.byu.edu">jay@cs.byu.edu</a>><br>
Assistant Professor / Brigham Young University<br>
<a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br>
<br>
"The glory of God is Intelligence" - D&C 93<br>
</div></div></blockquote></div><br></div>