Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with proxy use when splitting headers and response #60

Open
Kimotu opened this issue Jan 15, 2025 · 0 comments
Open

Problem with proxy use when splitting headers and response #60

Kimotu opened this issue Jan 15, 2025 · 0 comments

Comments

@Kimotu
Copy link

Kimotu commented Jan 15, 2025

When using a proxy, there is more than one newline in header. So the splitting into header and response is wrong and thus decode_response() does not work.

My workaround for json is $json_response = json_decode(strstr($api->response,'{')).

Full response:

HTTP/1.1 200 Connection established
Proxy-Agent: Fortinet-Proxy/1.0

HTTP/2 200
x-powered-by: PHP/8.2.26
expires: Thu, 19 Nov 1981 08:52:00 GMT
cache-control: no-cache
pragma: no-cache
vary: Accept-Encoding
SameSite=Strict; Secure; HttpOnly;
content-type: application/json; charset=utf-8
date: Wed, 15 Jan 2025 09:22:48 GMT
server: Apache

{"_meta": {"hostvars": {}}}

php-restclient splitted response:
header:

HTTP/1.1 200 Connection established
Proxy-Agent: Fortinet-Proxy/1.0

response:

HTTP/2 200
x-powered-by: PHP/8.2.26
expires: Thu, 19 Nov 1981 08:52:00 GMT
cache-control: no-cache
pragma: no-cache
vary: Accept-Encoding
SameSite=Strict; Secure; HttpOnly;
content-type: application/json; charset=utf-8
date: Wed, 15 Jan 2025 09:22:48 GMT
server: Apache

{"_meta": {"hostvars": {}}}

Correct splitted response:
header:

HTTP/1.1 200 Connection established
Proxy-Agent: Fortinet-Proxy/1.0

HTTP/2 200
x-powered-by: PHP/8.2.26
expires: Thu, 19 Nov 1981 08:52:00 GMT
cache-control: no-cache
pragma: no-cache
vary: Accept-Encoding
SameSite=Strict; Secure; HttpOnly;
content-type: application/json; charset=utf-8
date: Wed, 15 Jan 2025 09:22:48 GMT
server: Apache

response:

{"_meta": {"hostvars": {}}}
@Kimotu Kimotu changed the title Problem with proxy use Problem with proxy use when splitting headers and response Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant