Skip to content

Http headers #3

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

Merged
merged 5 commits into from
Jun 28, 2017
Merged

Http headers #3

merged 5 commits into from
Jun 28, 2017

Conversation

pinkgothic
Copy link
Contributor

Hi, Marcelo!

Here's a pull request for the header topic. I wasn't entirely sure about the array_filter() that I put in - I took the larger number of failing tests without it as an indicator that adding it in might be truer to your intentions. (I didn't want to start putting in an if (!empty($options['headers'])) or similar highly specific code.)

Let me know if this is acceptable or if you'd like tweaks.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 97fffca on pinkgothic:http-headers into e784498 on mjacobus:master.

Copy link
Owner

@mjacobus mjacobus left a comment

Choose a reason for hiding this comment

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

Há! I knew that face was familiar. Now I saw the name =)

Thank you for your PR. Awesome job by the way, I do not believe that is your first =)

Only one mall thing I would change. Let me know what you think.

src/Json.php Outdated
@@ -57,27 +57,27 @@ public function getEndpoint()
return $this->endpoint;
}

public function get($path, array $params = [])
public function get($path, array $params = [], array $headers = [])
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think of renaming $headers to $options, and make 'headers' a optional key in options? I think it could make it more resilient to changes in the future, if we need any. As in:

$client->get('/foo', [], [ 'headers' => ['foo' => 'bar'] ]);

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'm not sure how many other options are typically passed and if we're not making people type more than necessary, but sure! I don't object. I'll fiddle with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this better? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, I noticed that I'd forgotten to fix the interface variable names (and their description), so I tweaked that with one of the latest commits.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling c9e483a on pinkgothic:http-headers into e784498 on mjacobus:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 4d10704 on pinkgothic:http-headers into e784498 on mjacobus:master.

Copy link
Owner

@mjacobus mjacobus left a comment

Choose a reason for hiding this comment

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

Awesome, danke!

Only 2 minor things.

*/
public function passesOnHeaders()
{
$this->mockClient()->request('GET', $this->url('/foo'), ['headers' => ['Content-Type' => 'application/json; charset=utf-8'], "query" => []])
Copy link
Owner

Choose a reason for hiding this comment

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

The above line is a bit too long and hard to read, IMO.
What do you think of...?

$options = [
    'headers' => ['Content-Type' => 'application/json; charset=utf-8'],
    'query' => []
];
$this->mockClient()->request('GET', $this->url('/foo'), $options)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -85,8 +85,8 @@ Only tested code will be accepted. Please follow fix the style guide.

Copy link
Owner

Choose a reason for hiding this comment

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

Can you please run those for some code standard fixes?

./vendor/bin/broc-code fix src
./vendor/bin/broc-code fix tests

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 did actually! (Well, bro-code, there was no broc-code - that's why I changed it in the README.md.) It didn't seem to have changed anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh - can confirm that it's working despite my scepticism, I put in your $options snippet above and it changed the indentation of the arrow slightly. :D

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 667a639 on pinkgothic:http-headers into e784498 on mjacobus:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 503a00a on pinkgothic:http-headers into e784498 on mjacobus:master.

@mjacobus
Copy link
Owner

Thank you for your contribution! =)

@mjacobus
Copy link
Owner

Fixes #2

@mjacobus mjacobus merged commit e6a507b into mjacobus:master Jun 28, 2017
@mjacobus
Copy link
Owner

One thing I forgot. README says nothing about the new feature =)

@pinkgothic
Copy link
Contributor Author

Ah! See, that's the sort of thing I didn't realise was my prerogative in a pull request. I'll fiddle something.

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

Successfully merging this pull request may close these issues.

3 participants