-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAcknowledge a HTTPExpectheader.booleancanWrite()booleancanWrite(int length) Deprecated.booleancanWriteChar(int length) Deprecated.voidclose()voidvoidflush()Flush the response.intGet the number of bytes buffered on OutputBuffer and ready to be sent.intprotected Executorvoidinitialize(HttpHeader outputHeader, boolean sendfileEnabled, org.glassfish.grizzly.filterchain.FilterChainContext ctx) booleanDeprecated.will always return truebooleanisClosed()voidnotifyCanWrite(org.glassfish.grizzly.WriteHandler handler) voidnotifyCanWrite(org.glassfish.grizzly.WriteHandler handler, int length) Deprecated.thelengthparameter will be ignored.voidvoidrecycle()Recycle the output buffer.voidbooleanvoidreset()Reset current response.voidsendfile(File file, long offset, long length, org.glassfish.grizzly.CompletionHandler<org.glassfish.grizzly.WriteResult> handler) Will useFileChannel.transferTo(long, long, java.nio.channels.WritableByteChannel)to send file to the remote endpoint.voidsendfile(File file, org.glassfish.grizzly.CompletionHandler<org.glassfish.grizzly.WriteResult> handler) Callswrite(file, 0, file.length()).voidsetAsyncEnabled(boolean asyncEnabled) Deprecated.voidsetBufferSize(int bufferSize) voidsetTrailers(Supplier<Map<String, String>> trailersSupplier) voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidvoidvoidwriteBuffer(org.glassfish.grizzly.Buffer buffer) Writes the contents of the specifiedBufferto the client.voidwriteByte(int b) voidwriteByteBuffer(ByteBuffer byteBuffer) Writes the contents of the specifiedByteBufferto the client.voidwriteChar(int c)
-
Field Details
-
LOGGER
-
sendfileEnabled
protected boolean sendfileEnabled
-
-
Constructor Details
-
OutputBuffer
public OutputBuffer()
-
-
Method Details
-
initialize
public void initialize(HttpHeader outputHeader, boolean sendfileEnabled, org.glassfish.grizzly.filterchain.FilterChainContext ctx) -
isAsyncEnabled
Deprecated.will always return trueReturns
trueif content will be written in a non-blocking fashion, otherwise returnsfalse.- Returns:
trueif content will be written in a non-blocking fashion, otherwise returnsfalse.- Since:
- 2.1.2
-
setAsyncEnabled
Deprecated.Sets the asynchronous processing state of thisOutputBuffer.- Parameters:
asyncEnabled-trueif thisOutputBufferwill write content without blocking. @since 2.1.2 @deprecated OutputBuffer always supports async mode
-
prepareCharacterEncoder
public void prepareCharacterEncoder() -
getBufferSize
public int getBufferSize() -
registerLifeCycleListener
-
removeLifeCycleListener
-
setBufferSize
public void setBufferSize(int bufferSize) -
reset
public void reset()Reset current response.- Throws:
IllegalStateException- if the response has already been committed
-
isClosed
public boolean isClosed()- Returns:
trueif this OutputBuffer is closed, otherwise returnsfalse.
-
getBufferedDataSize
public int getBufferedDataSize()Get the number of bytes buffered on OutputBuffer and ready to be sent.- Returns:
- the number of bytes buffered on OutputBuffer and ready to be sent.
-
recycle
public void recycle()Recycle the output buffer. This should be called when closing the connection. -
endRequest
- Throws:
IOException
-
acknowledge
Acknowledge a HTTPExpectheader. The response status code and reason phrase should be set before invoking this method.- Throws:
IOException- if an error occurs writing the acknowledgment.
-
writeChar
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
writeByte
- Throws:
IOException
-
write
- Throws:
IOException
-
sendfile
public void sendfile(File file, org.glassfish.grizzly.CompletionHandler<org.glassfish.grizzly.WriteResult> handler) Calls
write(file, 0, file.length()).- Parameters:
file- theFileto transfer.handler-CompletionHandlerthat will be notified of the transfer progress/completion or failure.- Throws:
IllegalArgumentException- iffileis null- Since:
- 2.2
- See Also:
-
sendfile
public void sendfile(File file, long offset, long length, org.glassfish.grizzly.CompletionHandler<org.glassfish.grizzly.WriteResult> handler) Will use
FileChannel.transferTo(long, long, java.nio.channels.WritableByteChannel)to send file to the remote endpoint. Note that all headers necessary for the file transfer must be set prior to invoking this method as this will case the HTTP header to be flushed to the client prior to sending the file content. This should also be the last call to write any content to the remote endpoint.It's required that the response be suspended when using this functionality. It will be assumed that if the response wasn't suspended when this method is called, that it's desired that this method manages the suspend/resume cycle.
- Parameters:
file- theFileto transfer.offset- the starting offset within the Filelength- the total number of bytes to transferhandler-CompletionHandlerthat will be notified of the transfer progress/completion or failure.- Throws:
IllegalArgumentException- if the response has already been committed at the time this method was invoked.IllegalStateException- if a file transfer request has already been made or if send file support isn't available.IllegalStateException- if the response was in a suspended state when this method was invoked, but noCompletionHandlerwas provided.- Since:
- 2.2
-
write
- Throws:
IOException
-
close
- Throws:
IOException
-
flush
Flush the response.- Throws:
IOException- an underlying I/O error occurred
-
writeByteBuffer
Writes the contents of the specified
Note, that passedByteBufferto the client.ByteBufferwill be directly used by underlying connection, so it could be reused only if it has been flushed.- Parameters:
byteBuffer- theByteBufferto write- Throws:
IOException- if an error occurs during the write
-
writeBuffer
Writes the contents of the specified
Note, that passedBufferto the client.Bufferwill be directly used by underlying connection, so it could be reused only if it has been flushed.- Parameters:
buffer- theBufferto write- Throws:
IOException- if an error occurs during the write
-
canWriteChar
Deprecated. -
canWrite
Deprecated.thelengthparameter will be ignored. Please usecanWrite().- See Also:
-
AsyncQueueWriter.canWrite(org.glassfish.grizzly.Connection, int)
-
canWrite
public boolean canWrite()- See Also:
-
Writer.canWrite(org.glassfish.grizzly.Connection)
-
notifyCanWrite
Deprecated.thelengthparameter will be ignored. Please usenotifyCanWrite(org.glassfish.grizzly.WriteHandler).- See Also:
-
AsyncQueueWriter.notifyWritePossible(org.glassfish.grizzly.Connection, org.glassfish.grizzly.WriteHandler, int)
-
notifyCanWrite
public void notifyCanWrite(org.glassfish.grizzly.WriteHandler handler) -
setTrailers
-
getTrailers
-
getThreadPool
- Returns:
Executor, which will be used for notifying user registeredWriteHandler.
-
lengthparameter will be ignored.