Add custom headers to HTTPRequest

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Add custom headers to HTTPRequest

Post by SparrowhawkMMU »

Hi Fred

Would it be possible to add an optional parameter to HTTPRequest to add custom headers ?

i.e. equivalent of something like this in JS:

Code: Select all

$.ajax({
    url: 'some/url/on/the/web/',
    headers: { 'x-super-spiderbasic-header': 'hello world' }
});
So in SB it would be something like:

Code: Select all

HTTPRequest(#PB_HTTP_POST, "some/url/on/the/web", "", @MyCallBack(), 0, "'x-super-spiderbasic-header':'hello world'")
Maybe there is a more elegant way of adding it in?

Thank you

(Edited: corrected my SB version to mirror the header in the JS version)
Last edited by SparrowhawkMMU on Tue Feb 16, 2016 3:13 pm, edited 1 time in total.
User avatar
SinisterSoft
Posts: 77
Joined: Sun Apr 06, 2014 11:41 pm
Location: Preston, UK
Contact:

Re: Add custom headers to HTTPRequest

Post by SinisterSoft »

+1
User avatar
Arbrakaan
Posts: 91
Joined: Mon Feb 24, 2014 10:54 pm
Location: Geneva
Contact:

Re: Add custom headers to HTTPRequest

Post by Arbrakaan »

+1
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Add custom headers to HTTPRequest

Post by SparrowhawkMMU »

Hi Fred,

Any news on whether this will be implemented? Not being able to set custom headers means that I cannot build front ends to certain APIs that mandate the use of specific headers such as Content-Type, Content-Length, Accept, etc as well as some custom X-something style headers.

Pretty please? :)

Thanks in hope/anticipation

PS - being able to access the response headers is needed too. Thank you!


Edit: corrected some typos
Last edited by SparrowhawkMMU on Wed Sep 07, 2016 3:26 pm, edited 1 time in total.
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: Add custom headers to HTTPRequest

Post by Fred »

Should be no problem to add
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Add custom headers to HTTPRequest

Post by SparrowhawkMMU »

You are a star, thank you :)
LuckyLuke
Posts: 20
Joined: Wed Oct 26, 2016 9:50 am

Re: Add custom headers to HTTPRequest

Post by LuckyLuke »

Using a map will allow you to add multiple headers.

Code: Select all

NewMap headers.s()
headers("x-super-spiderbasic-header") = "hello world"

HTTPRequest(#PB_HTTP_Post, "some/url/on/the/web", "", @MyCallBack(), 0, headers())
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Add custom headers to HTTPRequest

Post by SparrowhawkMMU »

Yes the ability to add more than 1 custom header is crucial. I like the idea of a map.

+1
SergeyA
Posts: 4
Joined: Mon May 12, 2014 3:23 pm

Re: Add custom headers to HTTPRequest

Post by SergeyA »

+1
User avatar
SparrowhawkMMU
Posts: 281
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: Add custom headers to HTTPRequest

Post by SparrowhawkMMU »

Just a polite request for info from @fred: do you have a feel for when this might get added to SB? I have a project that is currently paused due to it requiring JavaScript Web Tokens for which I need to be able to set the Authorization (with Bearer) header.

I know that you are busy getting SB2.0.0 and PB5.44LTS out of the door, but just a feel for a timescale would be very useful. I promise that I won't hold you to it! :D
Post Reply