guzzle / guzzle

Guzzle, an extensible PHP HTTP client
https://docs.guzzlephp.org/
MIT License
23.18k stars 2.41k forks source link

How to detect proxy request in log? #1676

Closed mikeevstropov closed 4 years ago

mikeevstropov commented 7 years ago

Hi. This is all what we can use for template.

/**
 * Formats log messages using variable substitutions for requests, responses,
 * and other transactional data.
 *
 * The following variable substitutions are supported:
 *
 * - {request}:        Full HTTP request message
 * - {response}:       Full HTTP response message
 * - {ts}:             ISO 8601 date in GMT
 * - {date_iso_8601}   ISO 8601 date in GMT
 * - {date_common_log} Apache common log date using the configured timezone.
 * - {host}:           Host of the request
 * - {method}:         Method of the request
 * - {uri}:            URI of the request
 * - {host}:           Host of the request
 * - {version}:        Protocol version
 * - {target}:         Request target of the request (path + query + fragment)
 * - {hostname}:       Hostname of the machine that sent the request
 * - {code}:           Status code of the response (if available)
 * - {phrase}:         Reason phrase of the response  (if available)
 * - {error}:          Any error messages (if available)
 * - {req_header_*}:   Replace `*` with the lowercased name of a request header to add to the message
 * - {res_header_*}:   Replace `*` with the lowercased name of a response header to add to the message
 * - {req_headers}:    Request headers
 * - {res_headers}:    Response headers
 * - {req_body}:       Request body
 * - {res_body}:       Response body
 */

Where is {proxy}?

https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php

mikeevstropov commented 7 years ago

I use example from https://goo.gl/TcQTcd but cant detect proxy request. Please, help anyone!

use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\MessageFormatter;
use Monolog\Logger;

$stack = HandlerStack::create();
$stack->push(
    Middleware::log(
        new Logger('Logger'),
        new MessageFormatter('{req_body} - {res_body} - {is_proxy???}')
    )
);
$client = new \GuzzleHttp\Client(
    [
        'base_uri' => 'http://httpbin.org',
        'handler' => $stack,
    ]
);
sagikazarmark commented 7 years ago

It seems to me that it is not implemented, and I think it's not possible to get the proxy in the message formatters since this information is not carried by the HTTP messages, sorry.

sagikazarmark commented 6 years ago

This issue was automatically classified as stale because it lacks information or cannot be reproduced.

If you think the issue is still valid and/or misclassified, please comment on the issue thread and provide additional information (if possible).

Also, since the time maintainers can spend on the project is limited, please provide a possible solution if possible, especially if it involves a platform that we cannot test ourselves (Windows, very old/specific PHP versions, etc).

Issues marked as stale with no further activity will be marked as rotten at some point and will automatically be closed within 14 days.

We do this so that we can focus on high priority issues. Thank you for your understanding.