Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Documented the new HttpClient component #11071

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

Closed
wants to merge 11 commits into from

Conversation

javiereguiluz
Copy link
Member

@javiereguiluz javiereguiluz added this to the 4.3 milestone Mar 1, 2019

You can either handle cookies yourself using the ``Cookie`` HTTP header or use
the :doc:`BrowserKit component </components/browser_kit>` which provides this
feature and integrates seamlessly with the HttpClient component.
Copy link
Member

@zanbaldwin zanbaldwin Mar 1, 2019

Choose a reason for hiding this comment

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

Some extra explanation is probably needed here.

I haven't seen anything in symfony/symfony#30413 relating to the BrowserKit component and the documentation for the Browser component states you must implement the doRequest(Request $request): Response method, meaning you'd have to:

  • Convert $request object to $httpClient->request($method, $url, $options)
  • Convert Symfony\Contracts\HttpClient\ResponseInterface to Symfony\Component\HttpFoundation\Response

This is non-trivial, and definitely not seamless. Perhaps an idea would be to add a static helper method (like Symfony\Component\HttpClient\HttpOptions::fromFoundationRequest($request)) and add an example in this section.

(I know you've mentioned you're also improving BrowserKit, and may have already addressed this - if so ignore this!)

EDIT I just read Fabien's slides and saw that there's going to be a new Symfony\Component\BrowserKit\BrowserClient(HttpClientInterface $client) class. Once that's merged in it would still be a good idea to show an example of that here 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

Perfectly explained! We need to wait for the merge of the BrowserKit improvements and then we'll add a mention here. Thanks.

// defining data using a regular string
'body' => 'raw data',

// using a closure to generate the uploaded data
Copy link
Member

Choose a reason for hiding this comment

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

Should we add some explanation of what the closure needs to return?

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

I like it!

-----------------------

HTTP/2 is only supported when using the cURL-based transport and the libcurl
version is >= 7.36.0. If you meet these requirements, you can enable HTTP/2
Copy link
Member

Choose a reason for hiding this comment

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

This is not the only requirement. Curl has to be compiled with libnghttp2 as well. Not sure if we should mention that though.
Basically, HTTP2 support is automatically enabled if your environment supports it.

},
]);

// Responses are lazy: this code is executed as soon as headers are received
Copy link
Member

Choose a reason for hiding this comment

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

This is not exactly true, is it?
We send the request as soon as you run the $response-getStatusCode().

@nicolas-grekas
Copy link
Member

@javiereguiluz do you think you'll be able to move this PR forward soonish?

@javiereguiluz
Copy link
Member Author

@nicolas-grekas as we discussed, I've finished most of this PR. I've added most of reviewer's suggestions too. The pending suggestions are the ones still visible (the fixed ones has been marked as "resolved"). This is now ready for you! Thanks.

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.

10 participants