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

Add support for httplug #112

Merged
merged 32 commits into from
Nov 3, 2017
Merged

Add support for httplug #112

merged 32 commits into from
Nov 3, 2017

Conversation

aaa2000
Copy link
Contributor

@aaa2000 aaa2000 commented Jun 25, 2017

Close #107

  • Fix failed tests and skipped test testImageFile
  • Update composer dependencies to a stable version
  • Check on a wallabag instance

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 98.42% when pulling 0394fc6 on aaa2000:support-httplug into 9018618 on j0k3r:master.

"php-http/client-implementation": "^1.0",
"php-http/httplug": "^1.0",
"php-http/message-factory": "^1.0",
"php-http/discovery": "^1.0",
Copy link
Collaborator

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.

Copy link
Owner

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, did not notice Wallabag is switching to PHP 5.6, at selfoss we still support 5.4 at least until Debian wheezy EOL.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Owner

@j0k3r j0k3r left a 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/).
Copy link
Owner

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

Copy link
Contributor Author

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'],
Copy link
Owner

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?

Copy link
Contributor Author

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

Copy link
Owner

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

Copy link
Contributor Author

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

$client->expects($this->any())
->method('get')
->willReturn($response);
for ($i = 0; $i < 10; $i++) {
Copy link
Owner

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?

Copy link
Contributor Author

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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 98.406% when pulling eb2d4d9 on aaa2000:support-httplug into 9018618 on j0k3r:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+1.3%) to 98.406% when pulling a75cefd on aaa2000:support-httplug into 9018618 on j0k3r:master.

@j0k3r j0k3r mentioned this pull request Oct 5, 2017
@aaa2000 aaa2000 force-pushed the support-httplug branch 2 times, most recently from f40a16c to 9d0c9ad Compare October 12, 2017 20:55
@aaa2000
Copy link
Contributor Author

aaa2000 commented Oct 12, 2017

@j0k3r I wish to test temporarily with a fork of httplug but I have the error

Failed to clone the git@github.com:aaa2000/client-common.git repository, try running in interactive mode so that you can enter your GitHub credentials
                                                                                                                                                               
  [RuntimeException]                                                                                                                                            

  Failed to execute git clone --mirror 'git@github.com:aaa2000/client-common.git' '/home/travis/.composer/cache/vcs/git-gh.neting.cc-aaa2000-client-common.git/'  

Do you know how to correct ?

@j0k3r
Copy link
Owner

j0k3r commented Oct 13, 2017

Looks like it was a temporary hit limit I've relaunch build and it works fine now.

@j0k3r
Copy link
Owner

j0k3r commented Oct 13, 2017

@aaa2000 if you want to join Gitter we could talk about that

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.528% when pulling 0135e00 on aaa2000:support-httplug into c467f10 on j0k3r:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 98.296% when pulling a9aa6a0 on aaa2000:support-httplug into c467f10 on j0k3r:master.

Copy link
Owner

@j0k3r j0k3r left a 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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to the passed what?

Copy link
Contributor Author

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

* @dataProvider dataForSinglePage
*/
public function testSinglePage($url, $expectedUrl, $singlePageUrl)
{
DnsMock::withMockedHosts([
'singlepage1.com' => [['type' => 'A', 'ip' => '93.184.216.34']],
Copy link
Owner

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IP from example.com

Copy link
Owner

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

Copy link
Contributor Author

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

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.529% when pulling 8fd760e on aaa2000:support-httplug into c467f10 on j0k3r:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.529% when pulling 0299d30 on aaa2000:support-httplug into c467f10 on j0k3r:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.529% when pulling 595999a on aaa2000:support-httplug into c467f10 on j0k3r:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.525% when pulling 06ff069 on aaa2000:support-httplug into c467f10 on j0k3r:master.

{
$this->options = $options ?: new Options();
$this->uriFactory = $uriFactory ?: UriFactoryDiscovery::find();
//TODO force using IPV4 ? @see SafeCurl::init()
Copy link
Contributor Author

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

Copy link
Owner

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 🤔

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 98.525% when pulling e23ab8a on aaa2000:support-httplug into c467f10 on j0k3r:master.

*
* @see https://github.com/j0k3r/safecurl
* @see https://whitton.io/articles/safecurl-ssrf-protection-and-a-capture-the-bitcoins/
*/
Copy link
Contributor Author

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

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might a good idea.

@j0k3r j0k3r changed the base branch from master to 2.0 October 23, 2017 13:42
@j0k3r j0k3r added this to the 2.0 milestone Oct 23, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 98.424% when pulling 90eb474 on aaa2000:support-httplug into 19c8a37 on j0k3r:2.0.

// add referer for picky sites
'Referer' => $this->getReferer($url, $httpHeader),
],
'timeout' => $this->config['timeout'],
Copy link
Owner

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",
Copy link
Owner

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?

Copy link
Contributor Author

@aaa2000 aaa2000 Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anymore, fixed.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 98.424% when pulling 0fb652a on aaa2000:support-httplug into 19c8a37 on j0k3r:2.0.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 98.424% when pulling 6003896 on aaa2000:support-httplug into 19c8a37 on j0k3r:2.0.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 98.424% when pulling bdf4208 on aaa2000:support-httplug into 19c8a37 on j0k3r:2.0.

@j0k3r j0k3r merged commit ebb3d80 into j0k3r:2.0 Nov 3, 2017
@j0k3r
Copy link
Owner

j0k3r commented Nov 3, 2017

👏 !

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

Successfully merging this pull request may close these issues.

4 participants