C - The type of objects written as the content of the response.public abstract class HttpServerResponse<C> extends ResponseContentWriter<C>
| Modifier | Constructor and Description |
|---|---|
protected |
HttpServerResponse(rx.Observable.OnSubscribe<java.lang.Void> f) |
| Modifier and Type | Method and Description |
|---|---|
abstract WebSocketHandshaker |
acceptWebSocketUpgrade(WebSocketHandler handler)
Accepts the upgrade to websockets, if requested and after sending a successful handshake response,
invokes the passed handler to handle the websocket connection.
|
abstract HttpServerResponse<C> |
addCookie(io.netty.handler.codec.http.cookie.Cookie cookie)
Adds the passed
cookie to this response. |
abstract HttpServerResponse<C> |
addDateHeader(java.lang.CharSequence name,
java.util.Date value)
Adds the passed header as a date value to this response.
|
abstract HttpServerResponse<C> |
addDateHeader(java.lang.CharSequence name,
java.lang.Iterable<java.util.Date> values)
Adds multiple date values for the passed header name to this response.
|
abstract HttpServerResponse<C> |
addHeader(java.lang.CharSequence name,
java.lang.Iterable<java.lang.Object> values)
Adds an HTTP header with the passed
name and values to this response. |
abstract HttpServerResponse<C> |
addHeader(java.lang.CharSequence name,
java.lang.Object value)
Adds an HTTP header with the passed
name and value to this response. |
abstract boolean |
containsHeader(java.lang.CharSequence name)
Checks if there is a header with the passed name in this response.
|
abstract boolean |
containsHeader(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCaseValue)
Checks if there is a header with the passed name and value in this response.
|
abstract rx.Observable<java.lang.Void> |
dispose()
Disposes this response.
|
abstract HttpServerResponse<C> |
flushOnlyOnReadComplete()
This is a performance optimization to not flush the channel on every response send.
|
abstract java.util.List<java.lang.String> |
getAllHeaderValues(java.lang.CharSequence name)
Returns the values of headers with the specified name
|
abstract long |
getDateHeader(java.lang.CharSequence name)
Returns the date header value with the specified header name.
|
abstract long |
getDateHeader(java.lang.CharSequence name,
long defaultValue)
Returns the date header value with the specified header name.
|
abstract java.lang.String |
getHeader(java.lang.CharSequence name)
Returns the value of a header with the specified name.
|
abstract java.lang.String |
getHeader(java.lang.CharSequence name,
java.lang.String defaultValue)
Returns the value of a header with the specified name.
|
abstract java.util.Set<java.lang.String> |
getHeaderNames()
Returns a new
Set that contains the names of all headers in this response. |
abstract int |
getIntHeader(java.lang.CharSequence name)
Returns the integer header value with the specified header name.
|
abstract int |
getIntHeader(java.lang.CharSequence name,
int defaultValue)
Returns the integer header value with the specified header name.
|
abstract io.netty.handler.codec.http.HttpResponseStatus |
getStatus()
Returns the status of this response.
|
abstract HttpServerResponse<C> |
removeHeader(java.lang.CharSequence name)
Removes the passed header from this response.
|
abstract ResponseContentWriter<C> |
sendHeaders()
Sends the headers for this response when the returned
Observable is subscribed. |
abstract HttpServerResponse<C> |
setDateHeader(java.lang.CharSequence name,
java.util.Date value)
Overwrites the current value, if any, of the passed header to the passed date value for this response.
|
abstract HttpServerResponse<C> |
setDateHeader(java.lang.CharSequence name,
java.lang.Iterable<java.util.Date> values)
Overwrites the current value, if any, of the passed header to the passed date values for this response.
|
abstract HttpServerResponse<C> |
setHeader(java.lang.CharSequence name,
java.lang.Iterable<java.lang.Object> values)
Overwrites the current value, if any, of the passed header to the passed values for this response.
|
abstract HttpServerResponse<C> |
setHeader(java.lang.CharSequence name,
java.lang.Object value)
Overwrites the current value, if any, of the passed header to the passed value for this response.
|
abstract HttpServerResponse<C> |
setStatus(io.netty.handler.codec.http.HttpResponseStatus status)
Sets the status for the response.
|
abstract HttpServerResponse<C> |
setTransferEncodingChunked()
Sets the HTTP transfer encoding to chunked for this response.
|
abstract <CC> HttpServerResponse<CC> |
transformContent(io.reactivex.netty.channel.AllocatingTransformer<CC,C> transformer)
Creates a new
HttpServerResponse instance modifying the content type using the passed transformer. |
abstract HttpServerResponse<ServerSentEvent> |
transformToServerSentEvents()
Converts this response to enable writing
ServerSentEvents. |
abstract io.reactivex.netty.channel.Connection<?,?> |
unsafeConnection()
Returns the underlying connection on which this response was received.
|
abstract io.netty.channel.Channel |
unsafeNettyChannel()
Returns the underlying channel on which this response was received.
|
write, write, write, write, writeAndFlushOnEach, writeBytes, writeBytes, writeBytes, writeBytes, writeBytesAndFlushOnEach, writeString, writeString, writeString, writeString, writeStringAndFlushOnEachall, amb, amb, amb, amb, amb, amb, amb, amb, amb, ambWith, asObservable, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, buffer, cache, cache, cast, collect, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, combineLatest, compose, concat, concat, concat, concat, concat, concat, concat, concat, concat, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatEager, concatMap, concatMapEager, concatMapEager, concatWith, contains, count, countLong, create, debounce, debounce, debounce, defaultIfEmpty, defer, delay, delay, delay, delay, delaySubscription, delaySubscription, delaySubscription, dematerialize, distinct, distinct, distinctUntilChanged, distinctUntilChanged, doOnCompleted, doOnEach, doOnEach, doOnError, doOnNext, doOnRequest, doOnSubscribe, doOnTerminate, doOnUnsubscribe, elementAt, elementAtOrDefault, empty, error, exists, extend, filter, finallyDo, first, first, firstOrDefault, firstOrDefault, flatMap, flatMap, flatMap, flatMap, flatMap, flatMap, flatMapIterable, flatMapIterable, forEach, forEach, forEach, from, from, from, from, from, fromCallable, groupBy, groupBy, groupJoin, ignoreElements, interval, interval, interval, interval, isEmpty, join, just, just, just, just, just, just, just, just, just, just, last, last, lastOrDefault, lastOrDefault, lift, limit, map, materialize, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeDelayError, mergeWith, nest, never, observeOn, ofType, onBackpressureBuffer, onBackpressureBuffer, onBackpressureBuffer, onBackpressureDrop, onBackpressureDrop, onBackpressureLatest, onErrorResumeNext, onErrorResumeNext, onErrorReturn, onExceptionResumeNext, publish, publish, range, range, reduce, reduce, repeat, repeat, repeat, repeat, repeatWhen, repeatWhen, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, replay, retry, retry, retry, retryWhen, retryWhen, sample, sample, sample, scan, scan, sequenceEqual, sequenceEqual, serialize, share, single, single, singleOrDefault, singleOrDefault, skip, skip, skip, skipLast, skipLast, skipLast, skipUntil, skipWhile, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, startWith, subscribe, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeOn, switchIfEmpty, switchMap, switchOnNext, take, take, take, takeFirst, takeLast, takeLast, takeLast, takeLast, takeLast, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeLastBuffer, takeUntil, takeUntil, takeWhile, throttleFirst, throttleFirst, throttleLast, throttleLast, throttleWithTimeout, throttleWithTimeout, timeInterval, timeInterval, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timeout, timer, timer, timer, timer, timestamp, timestamp, toBlocking, toList, toMap, toMap, toMap, toMultimap, toMultimap, toMultimap, toMultimap, toSingle, toSortedList, toSortedList, toSortedList, toSortedList, unsafeSubscribe, unsubscribeOn, using, using, window, window, window, window, window, window, window, window, window, window, window, window, withLatestFrom, zip, zip, zip, zip, zip, zip, zip, zip, zip, zip, zipWith, zipWithprotected HttpServerResponse(rx.Observable.OnSubscribe<java.lang.Void> f)
public abstract io.netty.handler.codec.http.HttpResponseStatus getStatus()
HttpResponseStatus.OKpublic abstract boolean containsHeader(java.lang.CharSequence name)
name - Name of the header.true if there is a header with the passed name in this response.public abstract boolean containsHeader(java.lang.CharSequence name,
java.lang.CharSequence value,
boolean ignoreCaseValue)
name - Name of the header.value - Value of the header.ignoreCaseValue - true then the value comparision is done ignoring case.true if there is a header with the passed name and value in this response.public abstract java.lang.String getHeader(java.lang.CharSequence name)
name - The name of the header to searchnull if there is no such headerpublic abstract java.lang.String getHeader(java.lang.CharSequence name,
java.lang.String defaultValue)
name - The name of the header to searchdefaultValue - Default if the header does not exist.defaultValue if there is no such headerpublic abstract java.util.List<java.lang.String> getAllHeaderValues(java.lang.CharSequence name)
name - The name of the headers to searchList of header values which will be empty if no values are foundpublic abstract long getDateHeader(java.lang.CharSequence name)
throws java.text.ParseException
"E, dd MMM yyyy HH:mm:ss z"
name - The name of the header to searchjava.text.ParseException - if there is no such header or the header value is not a formatted datepublic abstract long getDateHeader(java.lang.CharSequence name,
long defaultValue)
"E, dd MMM yyyy HH:mm:ss z"
name - The name of the header to searchdefaultValue - Default value if there is no header with this name.defaultValue if there is no header with this name.public abstract int getIntHeader(java.lang.CharSequence name)
name - The name of the header to searchjava.lang.NumberFormatException - if there is no such header or the header value is not a numberpublic abstract int getIntHeader(java.lang.CharSequence name,
int defaultValue)
name - The name of the header to searchdefaultValue - Default if the header does not exist.defaultValue if there is no such header or the header value is not a
numberpublic abstract java.util.Set<java.lang.String> getHeaderNames()
Set that contains the names of all headers in this response. Note that modifying the
returned Set will not affect the state of this response.public abstract HttpServerResponse<C> addHeader(java.lang.CharSequence name, java.lang.Object value)
name and value to this response.name - Name of the header.value - Value for the header.thispublic abstract HttpServerResponse<C> addCookie(io.netty.handler.codec.http.cookie.Cookie cookie)
cookie to this response.cookie - Cookie to add.thispublic abstract HttpServerResponse<C> addDateHeader(java.lang.CharSequence name, java.util.Date value)
HttpHeaders.addDateHeader(HttpMessage, CharSequence, Date) which formats the date as per the
HTTP specifications into the format:
"E, dd MMM yyyy HH:mm:ss z"
name - Name of the header.value - Value of the header.thispublic abstract HttpServerResponse<C> addDateHeader(java.lang.CharSequence name, java.lang.Iterable<java.util.Date> values)
HttpHeaders.addDateHeader(HttpMessage, CharSequence, Date) which formats the date as per the
HTTP specifications into the format:
"E, dd MMM yyyy HH:mm:ss z"
name - Name of the header.values - Values for the header.thispublic abstract HttpServerResponse<C> addHeader(java.lang.CharSequence name, java.lang.Iterable<java.lang.Object> values)
name and values to this response.name - Name of the header.values - Values for the header.thispublic abstract HttpServerResponse<C> setDateHeader(java.lang.CharSequence name, java.util.Date value)
HttpHeaders.addDateHeader(HttpMessage, CharSequence, Date) which formats the date
as per the HTTP specifications into
the format:
"E, dd MMM yyyy HH:mm:ss z"
name - Name of the header.value - Value of the header.thispublic abstract HttpServerResponse<C> setHeader(java.lang.CharSequence name, java.lang.Object value)
name - Name of the header.value - Value of the header.thispublic abstract HttpServerResponse<C> setDateHeader(java.lang.CharSequence name, java.lang.Iterable<java.util.Date> values)
HttpHeaders.addDateHeader(HttpMessage, CharSequence, Date) which formats the
date as per the HTTP specifications
into the format:
"E, dd MMM yyyy HH:mm:ss z"
name - Name of the header.values - Values of the header.thispublic abstract HttpServerResponse<C> setHeader(java.lang.CharSequence name, java.lang.Iterable<java.lang.Object> values)
name - Name of the header.values - Values of the header.thispublic abstract HttpServerResponse<C> removeHeader(java.lang.CharSequence name)
name - Name of the header.thispublic abstract HttpServerResponse<C> setStatus(io.netty.handler.codec.http.HttpResponseStatus status)
status - Status to set.thispublic abstract HttpServerResponse<C> setTransferEncodingChunked()
HttpHeaders.setTransferEncodingChunked(HttpMessage)thispublic abstract HttpServerResponse<C> flushOnlyOnReadComplete()
Observable written). Something like this:
resp.sendHeaders()
.writeStringAndFlushOnEach(Observable.interval(1, TimeUnit.SECONDS))
.map(aLong -> "Interval =>" + aLong)
)
RequestHandler, something like:
response.writeString(Observable.just("Hello world");
When set, this will make the channel to be flushed only when all the requests available on the channel are
read. Thus, making it possible to do a gathering write for all pipelined requests on a connection. This reduces
the number of system calls and is helpful in "Hello World" benchmarks.public abstract ResponseContentWriter<C> sendHeaders()
Observable is subscribed. Alternatively, one can
continue to write contents using the returned ResponseContentWriterResponseContentWriter which can be subscribed to only send the headers or to write payload.@Experimental public abstract HttpServerResponse<ServerSentEvent> transformToServerSentEvents()
ServerSentEvents.ServerSentEvent enabled.public abstract <CC> HttpServerResponse<CC> transformContent(io.reactivex.netty.channel.AllocatingTransformer<CC,C> transformer)
HttpServerResponse instance modifying the content type using the passed transformer.CC - New type of the content.transformer - Transformer to transform the content stream.HttpServerResponse with the transformed content stream.public abstract WebSocketHandshaker acceptWebSocketUpgrade(WebSocketHandler handler)
WebSocketHandshaker for sending a handshake to the client. Subscription to the handshaker, will
send the handshake.public abstract rx.Observable<java.lang.Void> dispose()
Observable, subscription to which will dispose this response.public abstract io.netty.channel.Channel unsafeNettyChannel()
public abstract io.reactivex.netty.channel.Connection<?,?> unsafeConnection()