Skip to content

Commit

Permalink
Fixes #10105 - Document that Request objects are not reusable. (#10113)
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet authored Jul 17, 2023
1 parent af9d8d3 commit c967b10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ include::../../{doc_code}/org/eclipse/jetty/docs/programming/client/http/HTTPCli
You first create a request object using `httpClient.newRequest(...)`, and then you customize it using the fluent API style (that is, a chained invocation of methods on the request object).
When the request object is customized, you call `request.send()` that produces the `ContentResponse` when the request/response conversation is complete.

IMPORTANT: The `Request` object, despite being mutable, cannot be reused for other requests.
This is true also when trying to send two or more identical requests: you have to create two or more `Request` objects.

Simple `POST` requests also have a shortcut method:

[source,java,indent=0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
* <p>You can create {@link Request} objects via {@link HttpClient#newRequest(String)} and
* you can send them using either {@link #send()} for a blocking semantic, or
* {@link #send(Response.CompleteListener)} for an asynchronous semantic.</p>
* <p>{@link Request} objects cannot be reused for other requests, not even for requests
* that have identical URI and headers.</p>
*
* @see Response
*/
Expand Down

0 comments on commit c967b10

Please sign in to comment.