HTTPRequest and faulty headers from sender

Raspberry PI specific forum
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

HTTPRequest and faulty headers from sender

Post 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
Last edited by PeDe on Sat Aug 24, 2024 5:54 pm, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: HTTPRequest and faulty headers from sender

Post by Fred »

You can use the debug mode to have more info displayed in the console.
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: HTTPRequest and faulty headers from sender

Post 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
Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: HTTPRequest and faulty headers from sender

Post by Fred »

You can put the executable format in compiler options to console and it should do it
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: HTTPRequest and faulty headers from sender

Post 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

Fred
Administrator
Administrator
Posts: 18199
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: HTTPRequest and faulty headers from sender

Post by Fred »

Could you compare with the debug output of a working call ?
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: HTTPRequest and faulty headers from sender

Post by PeDe »

At the moment I don't see any possibility, the router always sends this wrong header.

Peter
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: HTTPRequest and faulty headers from sender

Post 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
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: HTTPRequest and faulty headers from sender

Post 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
PeDe
Enthusiast
Enthusiast
Posts: 281
Joined: Sun Nov 26, 2017 3:13 pm

Re: HTTPRequest and faulty headers from sender

Post 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
Post Reply