caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Alan Schmitt <alan.schmitt@polytechnique.org>,
	Gerd Stolpmann <info@gerd-stolpmann.de>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] ocamlnet question: get with arbitrary header
Date: Mon, 26 Mar 2018 14:04:37 +0200	[thread overview]
Message-ID: <218ae452-5704-79f5-dc4b-11d4278f20d9@gerd-stolpmann.de> (raw)
In-Reply-To: <m2zi2vidkj.fsf@polytechnique.org>


[-- Attachment #1.1: Type: text/plain, Size: 1773 bytes --]



On 26.03.18 07:57, Alan Schmitt wrote:
> Hello Gerd,
>
> On 2018-03-22 20:55, Gerd Stolpmann <info@gerd-stolpmann.de> writes:
>
>> No, with the Convenience module you cannot do it. It's really meant for
>> super-simple stuff only.
>>
>> But you can do:
>>
>> let pipeline = new Nethttp.pipeline in
>> let call = new Nethttp_client.get url in
>> call # set_request_header (new Netmime.basic_mime_header
>> ["Authorization", ...]);
>> pipeline # add call;
>> pipeline # run()
>>
>> then check for call # response_* values. You can reuse the pipeline
>> across calls.
> Thank you for the tip. The API I'm interacting with also uses the PATCH
> method, is there support for it in ocamlnet?


Well, you would have to create your own class for that, e.g. there is
for GET:

class get_call = object(self)   inherit generic_call   method private
fixup_request() = ()   method private def_request_method = "GET"  
method private def_is_idempotent = true   method private
def_has_req_body = false   method private def_has_resp_body = true  
method private def_empty_path_replacement = "/" end

class get the_query =   object (self)     inherit get_call    
initializer       self # set_request_uri the_query   end


For PATCH you'd have to define something along these lines. For other
examples like POST see the source code.

Gerd

> Best,
>
> Alan
>

-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2018-03-26 12:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-21 19:29 Alan Schmitt
2018-03-22 19:55 ` Gerd Stolpmann
2018-03-26  5:57   ` Alan Schmitt
2018-03-26 12:04     ` Gerd Stolpmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=218ae452-5704-79f5-dc4b-11d4278f20d9@gerd-stolpmann.de \
    --to=info@gerd-stolpmann.de \
    --cc=alan.schmitt@polytechnique.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).