Salut Fred,
Please could you add HttpInfo() to SB, as exists in PB? It's absence means I cannot use SB with many of the REST APIs that I use, as processing of the status code is critical in most of these scenarios. eg an API may well send back a 200 for a resource being successfully manipulated somehow, a 400 if the submitted paramers/headers were wrong, a 500 if the internal processing at the server end failed etc. And very often there is no body payload, just that code to indicate what happened..
Furthermore, I can't see how to get at return headers without this either, which prevents all kinds of functionality from being implemented, especially around authentication.
So unfortunately, despite the amazing new features in 3.00, I cannot use it yet for what I had in mind. Hopefully something that can be added to the .01 or .02 release?
Merci d'avance!
HttpInfo()
Re: HttpInfo()
You can overwrite HTTPRequest() and return the complete jqXHR object instead of 0 and 1 as the return value for Success. jqXHR contains status and statusText:
Code: Select all
! function spider_HTTPRequestNew(a, k, l, g, d, c) {
! "undefined" === typeof d && (d = 0);
! "undefined" === typeof c && (c = {
! map: {}
! });
! for (var f = Object.keys(c.map), h = {}, b = "GET", e = 0; e < f.length; e++)
! h[f[e]] = c.map[f[e]]._s;
! $.support.cors = !0;
! switch (a) {
! case 1:
! b = "POST";
! break;
! case 2:
! b = "PUT";
! break;
! case 4:
! b = "DELETE";
! break;
! case 3:
! b = "PATCH"
! }
! $.ajax({
! method: b,
! cache: !1,
! url: k,
! data: l,
! dataType: "html",
! headers: h,
! success: function(a, textStatus, jqXHR) {
! g(jqXHR, a, d)
! },
! error: function(jqXHR, textStatus, errorThrown) {
! g(jqXHR, "", d)
! }
! })
! }
! window.spider_HTTPRequest = spider_HTTPRequestNew;
Procedure HttpGetEvent(Success, Result$, UserData)
Protected Status.s
Protected StatusText.s
! v_status=v_success.status;
! v_statustext=v_success.statusText;
Debug Status
Debug StatusText
; Debug Result$
EndProcedure
; 1st request: 200 ok
HTTPRequest(#PB_HTTP_Get, #PB_Compiler_Filename, "", @HttpGetEvent())
; 2nd request: 404 error
HTTPRequest(#PB_HTTP_Get, #PB_Compiler_Filename + ".error", "", @HttpGetEvent())
Re: HttpInfo()
I guess it makes sens to add such function.
- SparrowhawkMMU
- Posts: 291
- Joined: Wed Aug 19, 2015 3:02 pm
- Location: United Kingdom
Re: HttpInfo()
Peter - thanks for that, I'll look into it to see whether it plugs the gap.
Fred - thank you, that would be fantastic.
Fred - thank you, that would be fantastic.
- SparrowhawkMMU
- Posts: 291
- Joined: Wed Aug 19, 2015 3:02 pm
- Location: United Kingdom
Re: HttpInfo()
Salut Fred,
Can you tell us whether this feature will be included in a 3.0.x release? I'm now at the stage where I have to decide on using something else for an admin app I wanted to make in SB. But it needs full access to HTTP verbs, headers, status codes as the service is REST based.
Not pushing you to commit, it's up to you what you add, and I know mobile has a higher priority with most people, but just checking in case you are working on it.
Thanks.
Can you tell us whether this feature will be included in a 3.0.x release? I'm now at the stage where I have to decide on using something else for an admin app I wanted to make in SB. But it needs full access to HTTP verbs, headers, status codes as the service is REST based.
Not pushing you to commit, it's up to you what you add, and I know mobile has a higher priority with most people, but just checking in case you are working on it.
Thanks.