-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Add support for httplug #112
Conversation
"php-http/client-implementation": "^1.0", | ||
"php-http/httplug": "^1.0", | ||
"php-http/message-factory": "^1.0", | ||
"php-http/discovery": "^1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will require PHP 5.5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine to me.
Jumping to httplug will force a new major release (ie 2.0.0) so we can increase the minimum version of PHP in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add PHP 5.5 requirement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that j0k3r/safecurl
will no longer be used, I must analyse his behaviour to reimplement with httplug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good job!
README.md
Outdated
composer require j0k3r/graby | ||
composer require j0k3r/graby php-http/guzzle5-adapter | ||
|
||
Why `php-http/guzzle6-adapter`? Because Graby is decoupled form any HTTP messaging client with help by [HTTPlug](http://httplug.io/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be php-http/guzzle5-adapter
?
Or the line above is wrong and should be php-http/guzzle6-adapter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
// add referer for picky sites | ||
'Referer' => $this->getReferer($url, $httpHeader), | ||
], | ||
'timeout' => $this->config['timeout'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't configure timeout anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, not easily. Each adapter has a different configuration. We must configure a client manually and inject it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be defined somewhere in the README
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a paragraph Timeout configuration
in the README
tests/Extractor/HttpClientTest.php
Outdated
$client->expects($this->any()) | ||
->method('get') | ||
->willReturn($response); | ||
for ($i = 0; $i < 10; $i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why will it be called 10 times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration of redirection by httplug was incorrect and the test was not well implemented, I changed it. Is it better ?
->method('get') | ||
->willReturn($response); | ||
], | ||
<<<"HTML" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
f40a16c
to
9d0c9ad
Compare
@j0k3r I wish to test temporarily with a fork of httplug but I have the error
Do you know how to correct ? |
Looks like it was a temporary hit limit I've relaunch build and it works fine now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove your "php-http/client-common": "dev-cookie-date as 1.4.x-dev",
from composer.json
OK I reviewed only the first new commit 😓
} | ||
|
||
/** | ||
* Sets a list to the passed in array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to the passed what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy paste from safecurl, I will fix it later
tests/GrabyTest.php
Outdated
* @dataProvider dataForSinglePage | ||
*/ | ||
public function testSinglePage($url, $expectedUrl, $singlePageUrl) | ||
{ | ||
DnsMock::withMockedHosts([ | ||
'singlepage1.com' => [['type' => 'A', 'ip' => '93.184.216.34']], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it some random IP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IP from example.com
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should put it in a constant to avoid XX updates if example.com changes its dns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Others are random ip. 93.184.216.34
is example.com
. The test use a http mock client, so a change doesn't impact the test. I will add a constant for the IP, it improves readability
{ | ||
$this->options = $options ?: new Options(); | ||
$this->uriFactory = $uriFactory ?: UriFactoryDiscovery::find(); | ||
//TODO force using IPV4 ? @see SafeCurl::init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that It is possible to do that with php-http
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't need it 🤔
* | ||
* @see https://github.com/j0k3r/safecurl | ||
* @see https://whitton.io/articles/safecurl-ssrf-protection-and-a-capture-the-bitcoins/ | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, the plugin should be extract in his own repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might a good idea.
// add referer for picky sites | ||
'Referer' => $this->getReferer($url, $httpHeader), | ||
], | ||
'timeout' => $this->config['timeout'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be defined somewhere in the README
composer.json
Outdated
"php-http/message-factory": "^1.0", | ||
"php-http/discovery": "^1.0", | ||
"php-http/client-common": "^1.6@dev", | ||
"php-http/message": "^1.6@dev", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need the @dev
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not anymore, fixed.
6003896
to
253e615
Compare
This reverts commit 588bd5f.
In order to void endless head request
253e615
to
bdf4208
Compare
👏 ! |
Close #107
testImageFile