Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
cookies in netclient
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Hendrik Tews <tews@c...>
Subject: Re: [Caml-list] cookies in netclient
Gerd Stolpmann <> writes:

   >    Unfortunately, get_set_cookie is missing (I have an implementation if
   >    you really need it).
   > This one would retrieve the cookies as an Nethttp.cookie list? I
   > don't know yet if I need it.

   yes. You find it if you need it:

In my opinion it would be more convenient to have something of

   #Nethttp.http_header_ro -> Nethttp.cookie list


let get_set_cookies mh = get_set_cookie (mh#multiple_field "set-cookie")

Further I propose to add a function to set cookies that accepts a
cookie list, like 

let set_cookies mh l = 
  Nethttp.Header.set_cookie mh 
    ( (fun c -> (c.Nethttp.cookie_name, c.Nethttp.cookie_value)) l)

The docs for http_call#request_header says

 The user should set the following headers:

    * Content-length: Set this to the length of the request body
      if known. (The client falls back to HTTP 1.0 if not set!) 

Do I have to care about this when using

>From what I read in the docs, it was not clear to me if
#request_header returns a copy of the header. I.e. do I have to
#set_request_header after modifying the header? (It works
without, so I guess #request_header does not copy.)

Yet another question: The docs for Netmime.mime_body_ro#value
says it will return the decoded body. But in which encoding? For
instance, if I want to extract pieces of an html page, what
should I pass as in_enc:Netconversion.encoding to
Netencoding.Html.decode? (At the moment decode_to_latin1 works
fine with me, but that's probably not the right way.)

Ocamlnet works now fine for me: Thanks for this great package!