- java.lang.Object
-
- org.eclipse.jetty.client.util.AbstractRequestContent
-
- org.eclipse.jetty.client.util.PathRequestContent
-
- All Implemented Interfaces:
Request.Content
public class PathRequestContent extends AbstractRequestContent
A
Request.Contentfor files using JDK 7'sjava.nio.fileAPIs.It is possible to specify, at the constructor, a buffer size used to read content from the stream, by default 4096 bytes. If a
ByteBufferPoolis provided viasetByteBufferPool(ByteBufferPool), the buffer will be allocated from that pool, otherwise one buffer will be allocated and used to read the file.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.client.util.AbstractRequestContent
AbstractRequestContent.AbstractSubscription, AbstractRequestContent.Producer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.client.api.Request.Content
Request.Content.Consumer, Request.Content.Subscription
-
-
Constructor Summary
Constructors Constructor Description PathRequestContent(java.lang.String contentType, java.nio.file.Path filePath)PathRequestContent(java.lang.String contentType, java.nio.file.Path filePath, int bufferSize)PathRequestContent(java.nio.file.Path filePath)PathRequestContent(java.nio.file.Path filePath, int bufferSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBufferPoolgetByteBufferPool()longgetLength()booleanisReproducible()Whether this content producer can produce exactly the same content more than once.booleanisUseDirectByteBuffers()protected Request.Content.SubscriptionnewSubscription(Request.Content.Consumer consumer, boolean emitInitialContent)voidsetByteBufferPool(ByteBufferPool byteBufferPool)voidsetUseDirectByteBuffers(boolean useDirectByteBuffers)-
Methods inherited from class org.eclipse.jetty.client.util.AbstractRequestContent
getContentType, subscribe
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.client.api.Request.Content
fail
-
-
-
-
Constructor Detail
-
PathRequestContent
public PathRequestContent(java.nio.file.Path filePath) throws java.io.IOException- Throws:
java.io.IOException
-
PathRequestContent
public PathRequestContent(java.nio.file.Path filePath, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
PathRequestContent
public PathRequestContent(java.lang.String contentType, java.nio.file.Path filePath) throws java.io.IOException- Throws:
java.io.IOException
-
PathRequestContent
public PathRequestContent(java.lang.String contentType, java.nio.file.Path filePath, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
getLength
public long getLength()
- Returns:
- the content length, if known, or -1 if the content length is unknown
-
isReproducible
public boolean isReproducible()
Description copied from interface:Request.ContentWhether this content producer can produce exactly the same content more than once.
Implementations should return
trueonly if the content can be produced more than once, which means thatRequest.Content.subscribe(Consumer, boolean)may be called again.The
HttpClientimplementation may use this method in particular cases where it detects that it is safe to retry a request that failed.- Returns:
- whether the content can be produced more than once
-
getByteBufferPool
public ByteBufferPool getByteBufferPool()
-
setByteBufferPool
public void setByteBufferPool(ByteBufferPool byteBufferPool)
-
isUseDirectByteBuffers
public boolean isUseDirectByteBuffers()
-
setUseDirectByteBuffers
public void setUseDirectByteBuffers(boolean useDirectByteBuffers)
-
newSubscription
protected Request.Content.Subscription newSubscription(Request.Content.Consumer consumer, boolean emitInitialContent)
- Specified by:
newSubscriptionin classAbstractRequestContent
-
-