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

User-agent is not passing properly in some case #162

Closed
amkoro opened this issue Aug 19, 2018 · 6 comments
Closed

User-agent is not passing properly in some case #162

amkoro opened this issue Aug 19, 2018 · 6 comments
Assignees

Comments

@amkoro
Copy link

amkoro commented Aug 19, 2018

After j0k3r/safecurl package was updated to 2.0.3 it appears that User-Agent string is not passing properly while retrieving remote URL.
I'm using this code:

$options = [
    'extractor' => [
        'config_builder' => [
            'site_config' => ['/some/path'],
        ],
    ],
    'error_message' => 'my error message',
    'http_client' => [
        'timeout' => 60,
        'ua_browser' => 'my user agent string',
    ],
];

$defaults = [
    'cookies' => true,
    'allow_redirects' => [
        'max' => 3
    ],
];

$client = new Client(['handler' => new SafeCurlHandler(),
                      'defaults' => $defaults]);
$graby = new Graby($options, $client);

reverting j0k3r/safecurl to previous version solves the issue

@j0k3r j0k3r self-assigned this Aug 20, 2018
@j0k3r
Copy link
Owner

j0k3r commented Aug 20, 2018

Thanks for letting me know! I'll take a look

@j0k3r
Copy link
Owner

j0k3r commented Aug 20, 2018

This looks strange because the only change to SafeCurl was to always add this header Accept: */*: j0k3r/safecurl@2.0.2...master#diff-788df89fb53b1ab56b42871a2606b24b

And SafeCurl never take the user agent defined in the graby config.
It just validate the url is safe to be called.

Are you sure it's related to SafeCurl and not a change in graby for example?
Could you provide a better snippet on how I can reproduce the problem?

@amkoro
Copy link
Author

amkoro commented Aug 21, 2018

yes, I'm completely sure that latest safecurl causing the issue
below are the Phiremock headers list for both cases:

"j0k3r/safecurl": "*"

[headers] => stdClass Object
                (
                    [Host] => Array
                        (
                            [0] => 127.0.0.1:8001
                        )

                    [Accept-Encoding] => Array
                        (
                            [0] => deflate, gzip
                        )

                    [Accept] => Array
                        (
                            [0] => */*
                        )

                )

"j0k3r/safecurl": "2.0.2"

[headers] => stdClass Object
                (
                    [Host] => Array
                        (
                            [0] => 127.0.0.1:8001
                        )

                    [User-Agent] => Array
                        (
                            [0] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36
                        )

                    [Referer] => Array
                        (
                            [0] => http://www.google.co.uk/url?sa=t&source=web&cd=1
                        )

                )

@j0k3r
Copy link
Owner

j0k3r commented Aug 24, 2018

Yeah I understand your problem. But I don't know how to reproduce.

I still need a snippet to reproduce the bug: a php snippet where you test that functionality isn't working anymore and how you check that.

Once I'll get that piece of code I'll be able to fix the problem.

@j0k3r
Copy link
Owner

j0k3r commented Oct 17, 2018

I reverted the PR because we found other problem.
I'm still really interested in getting code from you to reproduce your bug so I might be able to fix it properly.

Is there any chance you can provide me the PHP code you are using to reproduce the bug?
Thanks 🙏

@j0k3r j0k3r closed this as completed Oct 17, 2018
@j0k3r
Copy link
Owner

j0k3r commented Oct 17, 2018

I released SafeCurl 2.0.4 to fix the problem.

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

2 participants