Version française
Home     About     Download     Resources     Contact us    
Browse thread
Basic Ocamlnet Question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gerd Stolpmann <info@g...>
Subject: Re: [Caml-list] Basic Ocamlnet Question
Am Dienstag, den 14.08.2007, 18:29 +0100 schrieb
Peter.Gregory@cis.strath.ac.uk:
> Hi,
> 
> I've just started messing about with ocamlnet, and have instantly run 
> into a problem.  I was trying to write some code that interfaced with  the
> backpack API (http://developer.37signals.com/backpack/).  I tried 
> tweaking one of the examples just to get a page listing, and wrote the 
> following:
> 
> 
> open Http_client.Convenience;;

The "convenience module" is only for simple requests. Do it as follows:

> let get_and_print url  =
>    let s = http_post url [("","<request> <token>mytoken</token>
> </request>")] in
>    print_string s;
>    flush stdout
> ;;

let get_and_print url =
  let msg = new post_raw url "<request> <token>mytoken</token> </request>" in
  (msg # request_header `Base) # update_field
     "content-type" "application/xml";
  let p = new pipeline in
  p # add msg;
  p # run();
  print_string msg#response_body#value
;;


Gerd

> 
> let () = get_and_print "http://pg.backpackit.com/ws/pages/all";;
> 
> 
> However, this doesn't work, as the header for the request should be 
> "Content-Type: application/xml".  How do I set the header for my request 
> in ocamlnet?
> 
> Thanks,
> Peter.
> 
> 
> 
> 
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
> 
-- 
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany 
gerd@gerd-stolpmann.de          http://www.gerd-stolpmann.de
Phone: +49-6151-153855                  Fax: +49-6151-997714
------------------------------------------------------------