Module io.helidon.webserver
Package io.helidon.webserver.http
Class ServerResponseBase<T extends ServerResponseBase<T>>
java.lang.Object
io.helidon.webserver.http.ServerResponseBase<T>
- Type Parameters:
T- type of the response extending this class to allow fluent API
- All Implemented Interfaces:
RoutingResponse,ServerResponse
public abstract class ServerResponseBase<T extends ServerResponseBase<T>>
extends Object
implements RoutingResponse
Base class for common server response tasks that can be shared across HTTP versions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final HeaderNameStream result trailer name.protected static final HeaderStream status trailers. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServerResponseBase(ConnectionContext ctx, ServerRequest request) Create server response. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidExecute after send runnables.protected OutputStreamcontentEncode(OutputStream outputStream) Encode content using requested/default content encoder.protected byte[]entityBytes(byte[] configuredEntity) Entity bytes encoded using content encoding.booleanisNexted()Whether this request is nexted (ServerResponse.next()was called).protected MediaContextGets media context for this response.next()Continue processing with the next route (and if none found, return aStatus.NOT_FOUND_404).Re-route using a different path.Re-route using a different path and query.reroutePrologue(HttpPrologue prologue) A new, rerouted prologue.voidReset routing information (nexted, rerouted etc.).voidsend()Send a response with no entity.voidSend an entity, aMediaContextwill be used to serialize the entity.booleanShould we reroute this exchange.status()Configured HTTP status, if not configured, returnsStatus.OK_200.Status of the response.Completed when last byte is buffered for socket write.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.helidon.webserver.http.RoutingResponse
commit, hasEntity, resetMethods inherited from interface io.helidon.webserver.http.ServerResponse
bytesWritten, contentLength, header, header, header, headers, isSent, outputStream, send, send, sink, status, streamFilter, streamResult, trailers
-
Field Details
-
STREAM_RESULT_NAME
Stream result trailer name. -
STREAM_TRAILERS
Stream status trailers.
-
-
Constructor Details
-
ServerResponseBase
Create server response.- Parameters:
ctx- contextrequest- server request
-
-
Method Details
-
status
Description copied from interface:ServerResponseStatus of the response.- Specified by:
statusin interfaceServerResponse- Parameters:
status- HTTP status- Returns:
- this instance
-
status
Description copied from interface:ServerResponseConfigured HTTP status, if not configured, returnsStatus.OK_200.- Specified by:
statusin interfaceServerResponse- Returns:
- status
-
send
public void send()Description copied from interface:ServerResponseSend a response with no entity.- Specified by:
sendin interfaceServerResponse
-
send
Description copied from interface:ServerResponseSend an entity, aMediaContextwill be used to serialize the entity.- Specified by:
sendin interfaceServerResponse- Parameters:
entity- entity object
-
whenSent
Description copied from interface:ServerResponseCompleted when last byte is buffered for socket write.- Specified by:
whenSentin interfaceServerResponse- Parameters:
listener- listener to add to list of listeners that will be triggered once response is sent- Returns:
- this instance
-
reroute
Description copied from interface:ServerResponseRe-route using a different path.- Specified by:
reroutein interfaceServerResponse- Parameters:
newPath- new path to use- Returns:
- this instance
-
reroute
Description copied from interface:ServerResponseRe-route using a different path and query.- Specified by:
reroutein interfaceServerResponse- Parameters:
path- new pathquery- new query- Returns:
- this instance
- See Also:
-
next
Description copied from interface:ServerResponseContinue processing with the next route (and if none found, return aStatus.NOT_FOUND_404). If any entity method was called, this method will throw an exception.- Specified by:
nextin interfaceServerResponse- Returns:
- this instance
-
resetRouting
public void resetRouting()Description copied from interface:RoutingResponseReset routing information (nexted, rerouted etc.).- Specified by:
resetRoutingin interfaceRoutingResponse
-
shouldReroute
public boolean shouldReroute()Description copied from interface:RoutingResponseShould we reroute this exchange.- Specified by:
shouldReroutein interfaceRoutingResponse- Returns:
- whether rerouting was requested
-
reroutePrologue
Description copied from interface:RoutingResponseA new, rerouted prologue.- Specified by:
rerouteProloguein interfaceRoutingResponse- Parameters:
prologue- current prologue- Returns:
- prologue to use when rerouting
-
isNexted
public boolean isNexted()Description copied from interface:RoutingResponseWhether this request is nexted (ServerResponse.next()was called).- Specified by:
isNextedin interfaceRoutingResponse- Returns:
- if nexted
-
mediaContext
Gets media context for this response.- Returns:
- the media context
-
entityBytes
protected byte[] entityBytes(byte[] configuredEntity) Entity bytes encoded using content encoding.- Parameters:
configuredEntity- plain bytes- Returns:
- encoded bytes
-
contentEncode
Encode content using requested/default content encoder.- Parameters:
outputStream- output stream to write encoded data to- Returns:
- output stream to write plain data to
-
afterSend
protected void afterSend()Execute after send runnables.
-