public static interface HttpRequest.BodyProcessor
String, byte[], File,
InputStream
. Other implementations can be provided.
The methods of this interface may be called from multiple threads, but only one method is invoked at a time, and behaves as if called from one thread.
See HttpRequest
for implementations that take request bodies
from byte arrays, Strings, Paths
etc.
Modifier and Type | Method | Description |
---|---|---|
default void |
onComplete() |
Called when the request body has been completely sent.
|
boolean |
onRequestBodyChunk(ByteBuffer buffer) |
Called to obtain a buffer of data to send.
|
default void |
onRequestError(Throwable t) |
Called if sending a request body fails.
|
long |
onRequestStart(HttpRequest hr,
LongConsumer flowController) |
Called before a request is sent.
|
long onRequestStart(HttpRequest hr, LongConsumer flowController) throws IOException
The flowController object must be used to manage the flow of
calls to onRequestBodyChunk(ByteBuffer)
. The typical usage
for a non-blocking processor is to call it once inside
onRequestStart() and once during each call to onRequestBodyChunk().
hr
- the requestflowController
- the HttpFlowControllerIOException
- if an I/O error occursdefault void onRequestError(Throwable t)
t
- the Throwable that caused the failureboolean onRequestBodyChunk(ByteBuffer buffer) throws IOException
buffer
- a ByteBuffer to write data intoIOException
- if an I/O error occursdefault void onComplete()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.
DRAFT 9-internal+0-2016-10-04-161205.jjg.dev.8159855.tools-spi