-
Notifications
You must be signed in to change notification settings - Fork 0
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
Http headers #3
Conversation
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.
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 = []) |
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.
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'] ]);
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'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.
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 this better? :)
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.
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.
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.
Awesome, danke!
Only 2 minor things.
tests/JsonTest.php
Outdated
*/ | ||
public function passesOnHeaders() | ||
{ | ||
$this->mockClient()->request('GET', $this->url('/foo'), ['headers' => ['Content-Type' => 'application/json; charset=utf-8'], "query" => []]) |
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 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)
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.
Done!
@@ -85,8 +85,8 @@ Only tested code will be accepted. Please follow fix the style guide. | |||
|
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.
Can you please run those for some code standard fixes?
./vendor/bin/broc-code fix src
./vendor/bin/broc-code fix tests
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 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.
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.
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
Thank you for your contribution! =) |
Fixes #2 |
One thing I forgot. README says nothing about the new feature =) |
Ah! See, that's the sort of thing I didn't realise was my prerogative in a pull request. I'll fiddle something. |
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 anif (!empty($options['headers']))
or similar highly specific code.)Let me know if this is acceptable or if you'd like tweaks.