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

Support custom HTTP headers #6

Closed
wants to merge 1 commit into from
Closed

Support custom HTTP headers #6

wants to merge 1 commit into from

Conversation

valga
Copy link
Contributor

@valga valga commented Mar 30, 2017

See #3.

@clue
Copy link
Owner

clue commented Apr 6, 2017

Nice, thanks for filing this! 👍

I like this feature and would love to get this in! :shipit: Unfortunately, the PR does not currently contain any documentation, examples or tests, so it's a bit unclear how this can be used from a consumer perspective.

May I ask you provide a update this with documentation and some example and tests? Thanks!

@valga valga changed the title Support for auth and custom headers Support for basic auth and custom headers Apr 7, 2017
@valga
Copy link
Contributor Author

valga commented Apr 7, 2017

@clue, docs, examples and tests are done.

But I've stuck with Travis. I used pecl_http extension to parse HTTP messages in tests. It turned out that PHP5 requires 2.6 branch of pecl_http, while PHP7 requires 3.1 branch, and it seems that HHVM doesn't like pecl_http at all.

Any idea how to deal with it?

@ghost
Copy link

ghost commented May 20, 2017

@clue Hi Christian. We've reached a bit of a bad situation... Valga extended this library to be able to communicate with Instagram's chat servers, for use in our very popular Instagram API repo.

Unfortunately it turns out that Composer cannot recursively load "repository forks", so now all our users will be stuck unable to download our library, until the changes are merged into this official repo and we no longer need to fork it. Ouch.

So today we learned the hard way that Composer cannot load forked repos from sublibraries. :-\

mgp25/Instagram-API#1263

Anyway, Valga is one of the most perfectionistic programmers I've ever seen and I can see that he's done a great job here too. Could you please see if you can merge the changes soonish? Until then our users will be unable to use our in-dev version of our library. Ouch.

@clue
Copy link
Owner

clue commented May 21, 2017

@SteveJobzniak Thanks for the ping :-) I agree that maintaining custom forks is a real PITA and this is actually a high quality PR by @valga, so I'll look into getting this in within the upcoming week :shipit:

@ghost
Copy link

ghost commented May 21, 2017

@clue Thank you very much, that's absolutely wonderful to hear. <3 :-)

@clue clue added this to the v1.2.0 milestone Jun 10, 2017
Copy link
Owner

@clue clue left a comment

Choose a reason for hiding this comment

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

@valga Thanks for this high quality PR!

I've decided to split this feature up into a dedicated PR so that basic proxy authentication support has recently been added via #14 (also ping @SteveJobzniak).

I'd like to get the custom headers feature in for the next release, what do you think about the below feedback? 👍

README.md Outdated
$proxy = new ProxyConnector('127.0.0.1:8080', $connector, array(
'X-Custom-Header' => 'Value',
));
```
Copy link
Owner

Choose a reason for hiding this comment

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

What happens if you pass common headers such as Host? See also below wrt Proxy-Authorization.

Does it make sense to pass a "template request object" here instead of passing raw header values? This would potentially allow further customizations of the request object without cluttering the API in the future.

README.md Outdated
```

It should be noted, that custom `Proxy-Authorization` header take precedence
over credentials passed in proxy address.
Copy link
Owner

Choose a reason for hiding this comment

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

I'm undecided on this, which one should have preference?

.travis.yml Outdated
@@ -11,6 +11,7 @@ php:
sudo: false

install:
- printf "\n" | pecl install -f pecl_http-2.6.0
Copy link
Owner

Choose a reason for hiding this comment

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

This can probably be avoided, see also #14

composer.json Outdated
@@ -26,6 +26,7 @@
},
"require-dev": {
"react/socket-client": "^0.5",
"clue/block-react": "^1.1"
"clue/block-react": "^1.1",
"ext-http": "*"
Copy link
Owner

Choose a reason for hiding this comment

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

See above, can probably be removed.

@valga
Copy link
Contributor Author

valga commented Jun 12, 2017

Whoa, there was so many changes, so I rewound the branch. Also, nice catch on urlencoded credentials.

I rewrote custom headers feature by using a HTTP request template. It is just a draft, I didn't update the docs yet.

Also, I didn't write a test set for custom headers, because I think we need to change the approach for testing outgoing HTTP requests. For now, we just compare them string-by-string. What do you think of running HTTP parser on them?

@valga valga changed the title Support for basic auth and custom headers Support custom HTTP headers Jun 12, 2017
@clue clue modified the milestones: v1.3.0, v1.2.0 Aug 28, 2017
@clue
Copy link
Owner

clue commented Feb 12, 2018

@valga Thank you for both the quick update and your patience!

Let's look into why this wasn't merged yet, I think it's about time :-) Functionally, I don't have any major objections with this PR. However, API-wise I'm not sure my suggestion to use a "template request" was a good idea to begin with. The provided example code probably looks a bit "strange" from a consumer perspective and I wonder if we really have a use case that justifies passing a full request object with all its properties (most of which are apparently unused).

What do you think about this? Does it make more sense to revert the API to use a simple assoc array for custom HTTP request headers again (possibly keeping parts of the implementation details)? Any input would be much appreciated! 👍

@clue clue removed this from the v1.3.0 milestone Feb 12, 2018
@valga
Copy link
Contributor Author

valga commented Feb 18, 2018

@clue Rebased with simple array for headers, and some tests.

@clue
Copy link
Owner

clue commented Oct 25, 2018

@valga Thank you for looking into this and keeping this updated! I've just merged #25 which builds on top of this and adds some documentation.

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.

2 participants