Page 1 of 2
Add custom headers to HTTPRequest
Posted: Fri Feb 12, 2016 4:19 pm
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)
Re: Add custom headers to HTTPRequest
Posted: Mon Feb 15, 2016 9:43 pm
by SinisterSoft
+1
Re: Add custom headers to HTTPRequest
Posted: Mon Feb 15, 2016 10:22 pm
by Arbrakaan
+1
Re: Add custom headers to HTTPRequest
Posted: Wed Sep 07, 2016 10:39 am
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
Re: Add custom headers to HTTPRequest
Posted: Wed Sep 07, 2016 1:21 pm
by Fred
Should be no problem to add
Re: Add custom headers to HTTPRequest
Posted: Wed Sep 07, 2016 3:25 pm
by SparrowhawkMMU
You are a star, thank you

Re: Add custom headers to HTTPRequest
Posted: Wed Nov 09, 2016 7:44 am
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())
Re: Add custom headers to HTTPRequest
Posted: Wed Nov 09, 2016 11:10 am
by SparrowhawkMMU
Yes the ability to add more than 1 custom header is crucial. I like the idea of a map.
+1
Re: Add custom headers to HTTPRequest
Posted: Wed Nov 09, 2016 11:41 am
by SergeyA
+1
Re: Add custom headers to HTTPRequest
Posted: Thu Dec 01, 2016 12:57 pm
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!
