Page 1 of 1

HTTPRequest and faulty headers from sender

Posted: Sat Aug 24, 2024 4:24 pm
by PeDe
PB v6.11/12b3 x64 ASM - Windows 7 / Raspberry Pi OS 12 64-bit

I use HTTPRequest to make settings on a router (Alcatel HH71). This works under Windows without errors.
With the Raspberry P400 and the current OS, HTTPRequest does not work, or the response from the router is not accepted.

Query of status code, error message and header with HTTPInfo after the HTTPRequest results:

Code: Select all

StatusCode: 0
ErrorMessage: Header without colon
Header:
HTTP/1.1 200 OK
Content-Type: application/json
x-content-type-options: nosniff
x-permitted-cross-domain-policies: master-only
Referrer-Policy: origin
X-Frame-Options: SAMEORIGIN
x-xss-protection: 1; mode=block
Content-Security-Policy: default-src 'self';style-src 'self' data:;img-src 'self' data:;font-src 'self' data:


The response is empty, although data should be present.

The complete header is returned under Windows:

Code: Select all

StatusCode: 200
ErrorMessage:
Header:
HTTP/1.1 200 OK
Content-Type: application/json
x-content-type-options: nosniff
x-permitted-cross-domain-policies: master-only
Referrer-Policy: origin
X-Frame-Options: SAMEORIGIN
x-xss-protection: 1; mode=block
Content-Security-Policy: default-src 'self';style-src 'self' data:;img-src 'self' data:;font-src 'self' data:
X-Content-Type-Options=nosniff
Pragma: no-cache
Cache-control: no-cache
Content-Length: 65

Apparently the response from the router is incorrect. Is there anything that can be done with the HTTPRequest, or is this a PB bug?

Peter

Re: HTTPRequest and faulty headers from sender

Posted: Sat Aug 24, 2024 4:49 pm
by Fred
You can use the debug mode to have more info displayed in the console.

Re: HTTPRequest and faulty headers from sender

Posted: Sat Aug 24, 2024 4:57 pm
by PeDe
I tried that, but I'm not very familiar with Linux yet.
When I start PB from the terminal, I get the message that the compiler is not started when I run the code.

Peter

Re: HTTPRequest and faulty headers from sender

Posted: Sat Aug 24, 2024 5:00 pm
by Fred
You can put the executable format in compiler options to console and it should do it

Re: HTTPRequest and faulty headers from sender

Posted: Sat Aug 24, 2024 5:13 pm
by PeDe
With PB v6.12b3 the call via the terminal does not work, the compiler is not started, but with PB v6.11 it works.

Peter

Here is the output:

Code: Select all

*   Trying 192.168.1.1:80...
* Connected to 192.168.1.1 (192.168.1.1) port 80 (#0)
> POST /jrd/webapi HTTP/1.1
Host: 192.168.1.1
User-Agent: Mozilla/5.0 Gecko/41.0 Firefox/41.0
Accept: */*
Origin: http://192.168.1.1
X-Requested-With: XMLHttpRequest
Content-Type: application/json;charset=utf-8
_TclRequestVerificationKey: KSDHSDFOGQ5WERYTUIQWERTYUISDFG1HJZXCVCXBN2GDSMNDHKVKFsVBNf
Referer: http://192.168.1.1/
Content-Length: 123

< HTTP/1.1 200 OK
< Content-Type: application/json
< x-content-type-options: nosniff
< x-permitted-cross-domain-policies: master-only
< Referrer-Policy: origin
< X-Frame-Options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< Content-Security-Policy: default-src 'self';style-src 'self' data:;img-src 'self' data:;font-src 'self' data:
* Header without colon
* Closing connection 0


Re: HTTPRequest and faulty headers from sender

Posted: Sat Aug 24, 2024 6:13 pm
by Fred
Could you compare with the debug output of a working call ?

Re: HTTPRequest and faulty headers from sender

Posted: Sat Aug 24, 2024 6:31 pm
by PeDe
At the moment I don't see any possibility, the router always sends this wrong header.

Peter

Re: HTTPRequest and faulty headers from sender

Posted: Sun Aug 25, 2024 6:51 am
by PeDe
I have now been able to test the code with Ubuntu 20.04 and 22.04 64-bit and PB v6.11/12b3.
The call via the terminal does not work with PB v6.12b3 either, only with PB v6.11.

However, the code works with both PB versions. Here is the output of PB v6.11 in the terminal:

Code: Select all

pedre@VAIO:~/Apps/purebasic-v611/compilers$ ./purebasic
*   Trying 192.168.1.1:80...
* TCP_NODELAY set
* Connected to 192.168.1.1 (192.168.1.1) port 80 (#0)
> POST /jrd/webapi HTTP/1.1
Host: 192.168.1.1
User-Agent: Mozilla/5.0 Gecko/41.0 Firefox/41.0
Accept: */*
Origin: http://192.168.1.1
X-Requested-With: XMLHttpRequest
Content-Type: application/json;charset=utf-8
_TclRequestVerificationKey: KSDHSDFOGQ5WERYTUIQWERTYUISDFG1HJZXCVCXBN2GDSMNDHKVKFsVBNf
Referer: http://192.168.1.1/
Content-Length: 64

* upload completely sent off: 64 out of 64 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json
< x-content-type-options: nosniff
< x-permitted-cross-domain-policies: master-only
< Referrer-Policy: origin
< X-Frame-Options: SAMEORIGIN
< x-xss-protection: 1; mode=block
< Content-Security-Policy: default-src 'self';style-src 'self' data:;img-src 'self' data:;font-src 'self' data:
< X-Content-Type-Options=nosniff
< Pragma: no-cache
< Cache-control: no-cache
< Content-Length: 126
< 
* Connection #0 to host 192.168.1.1 left intact
...
...

Peter

Re: HTTPRequest and faulty headers from sender

Posted: Mon Aug 26, 2024 7:56 pm
by PeDe
I have now tested with Debian 12.6.0 i386, and here there is also the status code 0 and the headers are not read because of the missing colon.

Peter

Re: HTTPRequest and faulty headers from sender

Posted: Fri Aug 30, 2024 9:21 am
by PeDe
I have now upgraded Ubuntu 22.04 to 24.04.1 and it no longer works. Again status code 0 and the headers are not read.

Once PB upgrades the 'libcurl' used, it probably won't work on Windows either.

Peter