Fixes #10105 - Document that Request objects are not reusable. (#10113)

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2023-07-17 16:44:44 +02:00 committed by GitHub
parent af9d8d3a32
commit c967b100e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -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]

View File

@ -43,6 +43,8 @@ import org.eclipse.jetty.util.Fields;
* <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
*/