Top Description Inners Fields Constructors Methods
org.eclipse.jetty.ee10.servlet

pack-priv Class ServletCoreResponse

extends Object
implements Response
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.server.Response, org.eclipse.jetty.io.Content.Sink
Imports
java.io.InputStreamReader, java.nio.ByteBuffer, java.util.EnumSet, .List, .ListIterator, .Objects, java.util.concurrent.CompletableFuture, java.util.function.Supplier, java.util.stream.Collectors, jakarta.servlet.http.HttpServletResponse, org.eclipse.jetty.http.HttpField, .HttpFields, .HttpHeader, .HttpHeaderValue, org.eclipse.jetty.io.ByteBufferInputStream, org.eclipse.jetty.server.Request, .Response, org.eclipse.jetty.util.BufferUtil, .Callback, .IO

A HttpServletResponse wrapped as a core Response. All write operations are internally converted to blocking writes on the servlet API.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Request
private final HttpFields.Mutable
private final boolean
private final HttpServletResponse
private final ServletContextResponse

Constructor Summary

AccessConstructor and Description
public
ServletCoreResponse(Request coreRequest, HttpServletResponse response, boolean included)

Method Summary

Modifier and TypeMethod and Description
public HttpFields.Mutable
public Request
public HttpServletResponse
public int
public Supplier<HttpFields>
public boolean
hasLastWrite()

Implements org.eclipse.jetty.server.Response.hasLastWrite.

Returns whether the last write has been initiated on the response.

public boolean
isCommitted()

Implements org.eclipse.jetty.server.Response.isCommitted.

Returns whether this response has already been committed.

public boolean
isCompletedSuccessfully()

Implements org.eclipse.jetty.server.Response.isCompletedSuccessfully.

Returns whether the response completed successfully.

private boolean
public void
reset()

Implements org.eclipse.jetty.server.Response.reset.

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

public void
setStatus(int
the response HTTP status code
code
)

Implements org.eclipse.jetty.server.Response.setStatus.

Set the response HTTP status code.
public void
setTrailersSupplier(Supplier<HttpFields>
a supplier for the HTTP trailers
trailers
)

Implements org.eclipse.jetty.server.Response.setTrailersSupplier.

Sets the supplier for the HTTP trailers.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
write(boolean
whether the ByteBuffer is the last to write
last
,
ByteBuffer
the ByteBuffer to write
byteBuffer
,
Callback
the callback to notify when the write operation is complete
callback
)

Implements org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

public CompletableFuture<Void>
writeInterim(int
the interim HTTP status code
status
,
HttpFields
the HTTP headers
headers
)

Implements org.eclipse.jetty.server.Response.writeInterim.

Writes an HTTP interim response, with the given HTTP status code and HTTP headers.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_coreRequestback to summary
private final Request _coreRequest
_httpFieldsback to summary
private final HttpFields.Mutable _httpFields
_includedback to summary
private final boolean _included
_responseback to summary
private final HttpServletResponse _response
_servletContextResponseback to summary
private final ServletContextResponse _servletContextResponse

Constructor Detail

ServletCoreResponseback to summary
public ServletCoreResponse(Request coreRequest, HttpServletResponse response, boolean included)

Method Detail

getHeadersback to summary
public HttpFields.Mutable getHeaders()

Implements org.eclipse.jetty.server.Response.getHeaders.

Returns:HttpFields.Mutable

Doc from org.eclipse.jetty.server.Response.getHeaders.

the response HTTP headers

Annotations
@Override
getRequestback to summary
public Request getRequest()

Implements org.eclipse.jetty.server.Response.getRequest.

Returns:Request

Doc from org.eclipse.jetty.server.Response.getRequest.

the Request associated with this Response

Annotations
@Override
getServletResponseback to summary
public HttpServletResponse getServletResponse()
getStatusback to summary
public int getStatus()

Implements org.eclipse.jetty.server.Response.getStatus.

Returns:int

Doc from org.eclipse.jetty.server.Response.getStatus.

the response HTTP status code

Annotations
@Override
getTrailersSupplierback to summary
public Supplier<HttpFields> getTrailersSupplier()

Implements org.eclipse.jetty.server.Response.getTrailersSupplier.

Returns:Supplier<HttpFields>

Doc from org.eclipse.jetty.server.Response.getTrailersSupplier.

a supplier for the HTTP trailers

Annotations
@Override
hasLastWriteback to summary
public boolean hasLastWrite()

Implements org.eclipse.jetty.server.Response.hasLastWrite.

Doc from org.eclipse.jetty.server.Response.hasLastWrite.

Returns whether the last write has been initiated on the response.

Returns:boolean

true if last==true has been passed to write(boolean, ByteBuffer, Callback).

Annotations
@Override
isCommittedback to summary
public boolean isCommitted()

Implements org.eclipse.jetty.server.Response.isCommitted.

Doc from org.eclipse.jetty.server.Response.isCommitted.

Returns whether this response has already been committed.

Committing a response means that the HTTP status code and HTTP headers cannot be modified anymore, typically because they have already been serialized and sent over the network.

Returns:boolean

whether this response has already been committed

Annotations
@Override
isCompletedSuccessfullyback to summary
public boolean isCompletedSuccessfully()

Implements org.eclipse.jetty.server.Response.isCompletedSuccessfully.

Doc from org.eclipse.jetty.server.Response.isCompletedSuccessfully.

Returns whether the response completed successfully.

The response HTTP status code, HTTP headers and content have been successfully serialized and sent over the network without errors.

Returns:boolean

whether the response completed successfully

Annotations
@Override
isWritingback to summary
private boolean isWriting()
resetback to summary
public void reset()

Implements org.eclipse.jetty.server.Response.reset.

Doc from org.eclipse.jetty.server.Response.reset.

Resets this response, clearing the HTTP status code, HTTP headers and HTTP trailers.

Annotations
@Override
setStatusback to summary
public void setStatus(int code)

Implements org.eclipse.jetty.server.Response.setStatus.

Doc from org.eclipse.jetty.server.Response.setStatus.

Set the response HTTP status code.

Parameters
code:int

the response HTTP status code

Annotations
@Override
setTrailersSupplierback to summary
public void setTrailersSupplier(Supplier<HttpFields> trailers)

Implements org.eclipse.jetty.server.Response.setTrailersSupplier.

Doc from org.eclipse.jetty.server.Response.setTrailersSupplier.

Sets the supplier for the HTTP trailers.

The method Supplier#get() may be called by the implementation multiple times, so it is important that the same value is returned in every invocation.

Example:

// Correct usage.
HttpFields.Mutable trailers = HttpFields.build();
response.setTrailersSupplier(() -> trailers);

// WRONG usage, as the value changes for
// every invocation of supplier.get().
response.setTrailersSupplier(() -> HttpFields.build());
Parameters
trailers:Supplier<HttpFields>

a supplier for the HTTP trailers

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
writeback to summary
public void write(boolean last, ByteBuffer byteBuffer, Callback callback)

Implements org.eclipse.jetty.server.Response.write.

Doc from org.eclipse.jetty.server.Response.write.

Writes the given ByteBuffer, notifying the Callback when the write is complete.

Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Callback and a call to this method.

The invocation of the passed Callback is serialized with previous calls of this method, so that it is not invoked until any invocation of the callback of a previous call to this method has returned.

Thus a Callback should not block waiting for a callback of a future call to this method.

Parameters
last:boolean

whether the ByteBuffer is the last to write

byteBuffer:ByteBuffer

the ByteBuffer to write

callback:Callback

the callback to notify when the write operation is complete

Annotations
@Override
writeInterimback to summary
public CompletableFuture<Void> writeInterim(int status, HttpFields headers)

Implements org.eclipse.jetty.server.Response.writeInterim.

Doc from org.eclipse.jetty.server.Response.writeInterim.

Writes an HTTP interim response, with the given HTTP status code and HTTP headers.

It is possible to write more than one interim response, for example in case of HttpStatus#EARLY_HINTS_103.

The returned CompletableFuture is notified of the result of this write, whether it succeeded or failed.

Parameters
status:int

the interim HTTP status code

headers:HttpFields

the HTTP headers

Returns:CompletableFuture<Void>

a CompletableFuture with the result of the write

Annotations
@Override
org.eclipse.jetty.ee10.servlet back to summary

private Class ServletCoreResponse.HttpServletResponseHttpFields

extends Object
implements Mutable
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.ee10.servlet.ServletCoreResponse.HttpServletResponseHttpFields
All Implemented Interfaces
org.eclipse.jetty.http.HttpFields.Mutable, org.eclipse.jetty.http.HttpFields, java.util.function.Supplier, java.lang.Iterable

Field Summary

Modifier and TypeField and Description
private final HttpServletResponse

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public HttpFields.Mutable
add(String
the non-null name of the field
name
,
String
the non-null value of the field
value
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds a new HttpField with the given name and string value.

public HttpFields.Mutable
add(HttpHeader
the non-null name of the field
header
,
HttpHeaderValue
the non-null value of the field
value
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds a new HttpField with the given name and value.

public HttpFields.Mutable
add(HttpHeader
the non-null name of the field
header
,
String
the non-null value of the field
value
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds a new HttpField with the given name and string value.

public HttpFields.Mutable
add(HttpField
the HttpField to add
field
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds the given HttpField to this instance.

public ListIterator<HttpField>
public HttpFields.Mutable
put(HttpField
the field to put
field
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

Puts the given HttpField into this instance.

public HttpFields.Mutable
put(String
the name of the field
name
,
String
the value of the field; if null the field is removed
value
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

This method behaves like remove(String) when the given value is null, otherwise behaves like put(HttpField).

public HttpFields.Mutable
put(HttpHeader
the name of the field
header
,
HttpHeaderValue
the value of the field; if null the field is removed
value
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

This method behaves like remove(HttpHeader) when the given value is null, otherwise behaves like put(HttpField).

public HttpFields.Mutable
put(HttpHeader
the name of the field
header
,
String
the value of the field; if null the field is removed
value
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

This method behaves like remove(HttpHeader) when the given value is null, otherwise behaves like put(HttpField).

public HttpFields.Mutable
put(String
the name of the field
name
,
List<String>
the List value of the field. If null the field is cleared.
list
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

Puts a field associated with a list of values.

public HttpFields.Mutable
remove(HttpHeader
the name of the fields to remove
header
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.remove.

Removes all the fields with the given name.

public HttpFields.Mutable
remove(EnumSet<HttpHeader>
the names of the fields to remove
fields
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.remove.

Removes all the fields with the given names.

public HttpFields.Mutable
remove(String
the name of the fields to remove
name
)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.remove.

Removes all the fields with the given name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_responseback to summary
private final HttpServletResponse _response

Constructor Detail

HttpServletResponseHttpFieldsback to summary
private HttpServletResponseHttpFields(HttpServletResponse response)

Method Detail

addback to summary
public HttpFields.Mutable add(String name, String value)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds a new HttpField with the given name and string value.

The new HttpField is added even if a field with the same name is already present.

Parameters
name:String

the non-null name of the field

value:String

the non-null value of the field

Returns:HttpFields.Mutable

this instance

Annotations
@Override
addback to summary
public HttpFields.Mutable add(HttpHeader header, HttpHeaderValue value)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds a new HttpField with the given name and value.

The new HttpField is added even if a field with the same name is already present.

Parameters
header:HttpHeader

the non-null name of the field

value:HttpHeaderValue

the non-null value of the field

Returns:HttpFields.Mutable

this instance

Annotations
@Override
addback to summary
public HttpFields.Mutable add(HttpHeader header, String value)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds a new HttpField with the given name and string value.

The new HttpField is added even if a field with the same name is already present.

Parameters
header:HttpHeader

the non-null name of the field

value:String

the non-null value of the field

Returns:HttpFields.Mutable

this instance

Annotations
@Override
addback to summary
public HttpFields.Mutable add(HttpField field)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.add.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.add.

Adds the given HttpField to this instance.

Parameters
field:HttpField

the HttpField to add

Returns:HttpFields.Mutable

this instance

Annotations
@Override
listIteratorback to summary
public ListIterator<HttpField> listIterator(int index)

Implements org.eclipse.jetty.http.HttpFields.listIterator.

Returns:ListIterator<HttpField>

Doc from org.eclipse.jetty.http.HttpFields.listIterator.

an iterator over the HttpFields in this HttpFields starting at the given index.

Annotations
@Override
putback to summary
public HttpFields.Mutable put(HttpField field)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.put.

Puts the given HttpField into this instance.

If a fields with the same name is present, the given field replaces it, and other existing fields with the same name are removed, so that only the given field will be present.

If a field with the same name is not present, the given field will be added.

Parameters
field:HttpField

the field to put

Returns:HttpFields.Mutable

this instance

Annotations
@Override
putback to summary
public HttpFields.Mutable put(String name, String value)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.put.

This method behaves like remove(String) when the given value is null, otherwise behaves like put(HttpField).

Parameters
name:String

the name of the field

value:String

the value of the field; if null the field is removed

Returns:HttpFields.Mutable

this instance

Annotations
@Override
putback to summary
public HttpFields.Mutable put(HttpHeader header, HttpHeaderValue value)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.put.

This method behaves like remove(HttpHeader) when the given value is null, otherwise behaves like put(HttpField).

Parameters
header:HttpHeader

the name of the field

value:HttpHeaderValue

the value of the field; if null the field is removed

Returns:HttpFields.Mutable

this instance

Annotations
@Override
putback to summary
public HttpFields.Mutable put(HttpHeader header, String value)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.put.

This method behaves like remove(HttpHeader) when the given value is null, otherwise behaves like put(HttpField).

Parameters
header:HttpHeader

the name of the field

value:String

the value of the field; if null the field is removed

Returns:HttpFields.Mutable

this instance

Annotations
@Override
putback to summary
public HttpFields.Mutable put(String name, List<String> list)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.put.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.put.

Puts a field associated with a list of values.

Parameters
name:String

the name of the field

list:List<String>

the List value of the field. If null the field is cleared.

Returns:HttpFields.Mutable

this builder

Annotations
@Override
removeback to summary
public HttpFields.Mutable remove(HttpHeader header)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.remove.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.remove.

Removes all the fields with the given name.

Parameters
header:HttpHeader

the name of the fields to remove

Returns:HttpFields.Mutable

this instance

Annotations
@Override
removeback to summary
public HttpFields.Mutable remove(EnumSet<HttpHeader> fields)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.remove.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.remove.

Removes all the fields with the given names.

Parameters
fields:EnumSet<HttpHeader>

the names of the fields to remove

Returns:HttpFields.Mutable

this instance

Annotations
@Override
removeback to summary
public HttpFields.Mutable remove(String name)

Overrides default org.eclipse.jetty.http.HttpFields.Mutable.remove.

Doc from org.eclipse.jetty.http.HttpFields.Mutable.remove.

Removes all the fields with the given name.

Parameters
name:String

the name of the fields to remove

Returns:HttpFields.Mutable

this instance

Annotations
@Override