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

provide analogue functionality to CURLINFO_HEADER_OUT #35

Closed
rcanavan opened this issue Apr 2, 2016 · 2 comments
Closed

provide analogue functionality to CURLINFO_HEADER_OUT #35

rcanavan opened this issue Apr 2, 2016 · 2 comments

Comments

@rcanavan
Copy link

rcanavan commented Apr 2, 2016

Sometimes, it's necessary to inspect the actual request including all header that have been sent. The PHP curl extension implements this via the CURLINFO_HEADER_OUT option. The patch below provides similar functionality for ext-http.

log_outgoing_headers.patch.txt

@m6w6
Copy link
Owner

m6w6 commented Jun 21, 2016

I just pushed http\Client::setDebug() in 1ac722a which should give you the necessary facility to implement your needs.

Thank you.

Example:

<?php
$c = new http\Client;
$c->enqueue(new http\Client\Request("GET", "https://m6w6.name"));

$c->setDebug(function(http\Client $c, http\Client\Request $r, int $type, string $data) {
    if ($type & http\Client::DEBUG_HEADER) {
        echo $data;
    }
});

$c->send();' 

Output:

GET / HTTP/1.1
Host: m6w6.name
User-Agent: PECL_HTTP/3.1.0dev PHP/7.1.0-dev libcurl/7.49.1
Accept: */*

HTTP/1.1 200 OK
Date: Tue, 21 Jun 2016 07:22:55 GMT
Server: Apache/2.4.10 (Debian)
Strict-Transport-Security: max-age=31536000; preload
Last-Modified: Wed, 01 Jun 2016 08:20:12 GMT
ETag: "19ee-53433289985eb"
Accept-Ranges: bytes
Content-Length: 6638
Vary: Accept-Encoding
Content-Type: text/html

@m6w6 m6w6 closed this as completed Jun 21, 2016
@afflerbach
Copy link

At first glimpse 1ac722a actually seems to satisfy our needs. Thanks very much!

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

No branches or pull requests

3 participants