10.0.0-dp-2 html5 and liburlLastRHHeaders()

Bernard Devlin bdrunrev at gmail.com
Thu Mar 17 09:07:21 EDT 2022


Hi Mark

Thank you for your response. However, I just tried in the Javascript
console of Safari, Chrome and Firefox and the local test server to which I
am POSTing  is returning the headers (as LC does when running not as HTML5).

Here's the JS I used. As you can see, it's a simple POST rather than
anything multipart.
------------

var json = JSON.stringify({ name: "John", surname: "Smith"});

var http = new XMLHttpRequest();

var url = 'http://192.168.0.34:8080/tabs/echo';

http.open('POST', url, true);

http.setRequestHeader('Content-type', 'application/json; charset=utf-8');

var result = 'comm with server failed';

http.onreadystatechange = function() {

   if (http.readyState == 4 && http.status == 200) {

   result=http.responseText;

   console.log(result);

   console.log( http.getAllResponseHeaders() );

   }

}

http.send(json);

>>
access-control-allow-origin: *
connection: keep-alive
content-length: 56
content-type: text/plain; charset=utf-8
date: Thu, 17 Mar 2022 12:53:21 GMT
server: NaviServer/4.99.20
<<

So there is something else going on between LC's libUrlLastRHHeaders() and
LC's interaction with the JS XMLHttpRequest().  This something is stripping
out most of the headers.

My next step is to turn that JS into a function that I can call from LC
within the context of the browser to see whether the full headers are
returned to LC from that JS call.

Regards
Bernard

On Thu, Mar 17, 2022 at 9:58 AM Mark Waddingham via use-livecode <
use-livecode at lists.runrev.com> wrote:

>
>
> We already use that JS API to implement lastRHHeaders - we just return
> the value it returns verbatim.
>
> Therefore, I'm guessing this is something the API is doing. The only
> thing which may give a hint is (in that doc):
>
>    'For multipart requests, this returns the headers from the current
> part of the request, not from the original channel.'
>
> Not sure whether that applies in this case or not (except that POST is
> generally used in multipart requests I think...)
>
> Anyway, file a bug with an example if you can and we'll take a look.
>
>


More information about the use-livecode mailing list