-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Conversation
|
||
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. |
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.
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
toSymfony\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 🙂
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.
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 |
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.
Should we add some explanation of what the closure needs to return?
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 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 |
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.
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 |
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.
This is not exactly true, is it?
We send the request as soon as you run the $response-getStatusCode().
@javiereguiluz do you think you'll be able to move this PR forward soonish? |
422a119
to
a1fe401
Compare
@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. |
All suggestions have been implemented
Docs for symfony/symfony#30413.