Skip to content

Problem with proxy use when splitting headers and response #60

Description

@Kimotu

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": {}}}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions