• http.js

    From Kirkman@VERT/GUARDIAN to All on Friday, February 28, 2014 12:52:32
    Does http.js allow for customization of the headers sent in a request?

    I'm playing around with parsing some json apis, and some of them require that you add a header of the form "Bearer " + token.

    --Josh

    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog


    ---
    þ Synchronet
  • From Deuce@VERT/SYNCNIX to Kirkman on Saturday, March 01, 2014 15:14:39
    Re: http.js
    By: Kirkman to All on Fri Feb 28 2014 12:52 pm

    Does http.js allow for customization of the headers sent in a request?

    Absolutely, you need to create the request, modify it, then send it like so:

    req = new HTTPRequest();
    req.SetupGet("http://example.com");
    req.request_headers.push("X-Magic: More magic");
    req.SendRequest();
    req.ReadResponse();
    response = req.body;

    Have a look at the Get() method in http.js for how to do auth and such.

    ---
    http://DuckDuckGo.com/ a better search engine that respects your privacy.
    þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)
  • From Kirkman@VERT/GUARDIAN to Deuce on Saturday, March 01, 2014 18:21:14
    Re: http.js
    By: Deuce to Kirkman on Sat Mar 01 2014 03:14 pm

    Absolutely, you need to create the request, modify it, then send it like
    so:

    req = new HTTPRequest();
    req.SetupGet("http://example.com");
    req.request_headers.push("X-Magic: More magic");

    Awesome. That sounds like exactly what I need!

    --Josh


    ////--------------------------------------------------
    BiC -=- http://breakintochat.com -=- bbs wiki and blog


    ---
    þ Synchronet