-
Notifications
You must be signed in to change notification settings - Fork 818
Bug Fix - unsetHeader #237
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
Conversation
The unsetHeader bad work, for example $curl->setHeader('Host','example.com'); $curl->unsetHeader('Host'); $curl->get('http://127.0.0.1/'); --------- This request is make with Header "Host" = '' (empty string), because unsetHeader bad work with the my fix the header 'Host' with be deleted and curl auto-retrive the right header. horever is already possible make request with header 'Host' = '' (empty string) with $curl->setHeader('Host', '' ); also remove a bad comment about fuction * - * @return string in setHeader()
Hi.
|
Example test: // index.php
echo $_SERVER['HTTP_X_FOO']; $curl = new Curl();
$curl->setHeader('X-FOO', 'BAR');
$curl->post('http://127.0.0.1:8000');
echo $curl->rawResponse . "\n"; // returns 'BAR' $curl = new Curl();
$curl->setHeader('X-FOO', 'BAR');
$curl->unsetHeader('X-FOO');
$curl->post('http://127.0.0.1:8000');
echo $curl->rawResponse . "\n"; // returns 'Notice: Undefined index: HTTP_X_FOO' |
OK, you are right, I Dont know curl 100%, i'm sorry. but there are a problem: By Default Curl send the following headers with a value auto-retrieve: Request-Line , Host , Accept So if i force another value, for example for "Host" with $curl->setHeader('Host', 'example.com'); Don't exist a method, in your class for restore to 'Host' a default value that is auto-retrived I thought that unsetHeader will be planned for do this, but it is planned for Remove header, not for restore, so is missing a method: setDefaultHeader |
Horever in your class there're a bug, please try this
the header 'Host' will be reset to default value and it is present in the request unsetHeader() function must be edit and remove the unset
|
i was write the setDefaultHeader() method , please let see if everything is ok
I Thinks is all right now, Confirm ? |
Can you provide a use case for implementing |
As mentioned in #237 (comment), |
Additional note, think of |
Reopening to implement separate |
Thanks for the suggestion! |
There has a bug in unsetHeader()
The unsetHeader bad work,
for example
$curl->setHeader('Host','example.com');
$curl->unsetHeader('Host');
$curl->get('http://127.0.0.1/');
This request is make with Header "Host" = '' (empty string), because unsetHeader bad work
with the my fix the header 'Host' with be deleted and curl auto-retrive the right header.
horever is already possible make request with header 'Host' = '' (empty string) with $curl->setHeader('Host', '' );
also remove a bad comment about fuction