* Basic Ocamlnet Question
@ 2007-08-14 17:29 Peter.Gregory
2007-08-14 17:39 ` [Caml-list] " Oliver Bandel
2007-08-14 17:46 ` Gerd Stolpmann
0 siblings, 2 replies; 4+ messages in thread
From: Peter.Gregory @ 2007-08-14 17:29 UTC (permalink / raw)
To: caml-list
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;;
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 "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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Basic Ocamlnet Question
2007-08-14 17:29 Basic Ocamlnet Question Peter.Gregory
@ 2007-08-14 17:39 ` Oliver Bandel
2007-08-14 17:46 ` Gerd Stolpmann
1 sibling, 0 replies; 4+ messages in thread
From: Oliver Bandel @ 2007-08-14 17:39 UTC (permalink / raw)
To: caml-list
Zitat von 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;;
>
> 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 "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?
[...]
The Convenience-Module is very convenient for simple
things, IMHO.
I have tried it and found it very funny to use.
But I think for more sophisticated things you have to use the
other modules. I'm not sure, but I think (as far as I have
seen it) the Convenience-module is not powerful enough for
special things.
There are a lot of other modules that can do what you want.
(No example here, because for my simple needs when I have
looked at it, I was happy enough with the Convenience module).
Ciao,
Oliver
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Basic Ocamlnet Question
2007-08-14 17:29 Basic Ocamlnet Question Peter.Gregory
2007-08-14 17:39 ` [Caml-list] " Oliver Bandel
@ 2007-08-14 17:46 ` Gerd Stolpmann
2007-08-14 19:37 ` Peter.Gregory
1 sibling, 1 reply; 4+ messages in thread
From: Gerd Stolpmann @ 2007-08-14 17:46 UTC (permalink / raw)
To: Peter.Gregory; +Cc: caml-list
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
------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Basic Ocamlnet Question
2007-08-14 17:46 ` Gerd Stolpmann
@ 2007-08-14 19:37 ` Peter.Gregory
0 siblings, 0 replies; 4+ messages in thread
From: Peter.Gregory @ 2007-08-14 19:37 UTC (permalink / raw)
To: Gerd Stolpmann; +Cc: caml-list
> 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
>
Thanks Gerd, that works fine.
Peter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-14 19:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-14 17:29 Basic Ocamlnet Question Peter.Gregory
2007-08-14 17:39 ` [Caml-list] " Oliver Bandel
2007-08-14 17:46 ` Gerd Stolpmann
2007-08-14 19:37 ` Peter.Gregory
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox