WebServerDispatcher.Resource


public final class WebServerDispatcher.Resource


A resource served by WebServerDispatcher.

Summary

Nested types

Builder for Resource.

Constants

static final int

The server doesn't support gzip.

static final int

The server supports gzip.

static final int

The server supports gzip.

Public methods

WebServerDispatcher.Resource.Builder

Returns a new Builder initialized with the values from this instance.

byte[]

Returns the data served by this resource.

ImmutableListMultimap<StringString>

Returns the extra response headers that should be attached.

int

Returns the level of gzip support the server should provide for this resource.

int

The HTTP method that should be used to request the resource.

String

Returns the path this resource is available at.

byte[]

The body that should be included in a request for the resource.

ImmutableListMultimap<StringString>

The headers that should be included in a request for the resource.

boolean

Returns true if RFC 7233 HTTP 206 responses should include a Content-Length header.

boolean

Returns true if the resource should resolve to an unknown length.

boolean

Returns true if RFC 7233 range requests should be supported for this resource.

Constants

GZIP_SUPPORT_DISABLED

public static final int GZIP_SUPPORT_DISABLED = 1

The server doesn't support gzip.

GZIP_SUPPORT_ENABLED

public static final int GZIP_SUPPORT_ENABLED = 2

The server supports gzip. Responses are only compressed if the request signals "gzip" is an acceptable content-coding using an Accept-Encoding header.

GZIP_SUPPORT_FORCED

public static final int GZIP_SUPPORT_FORCED = 3

The server supports gzip. Responses are compressed if the request contains no Accept-Encoding header or one that accepts "gzip".

RFC 2616 14.3 recommends a server use "identity" content-coding if no Accept-Encoding is present, but some servers will still compress responses in this case. This option mimics that behaviour.

Public fields

data

public final byte[] data

extraResponseHeaders

public ImmutableListMultimap<StringStringextraResponseHeaders

gzipSupport

public final int gzipSupport

httpMethod

@DataSpec.HttpMethod
public final int httpMethod

path

public final String path

requestBody

public final byte[] requestBody

requestHeaders

public final ImmutableListMultimap<StringStringrequestHeaders

Public methods

buildUpon

public WebServerDispatcher.Resource.Builder buildUpon()

Returns a new Builder initialized with the values from this instance.

getData

public byte[] getData()

Returns the data served by this resource.

getExtraResponseHeaders

public ImmutableListMultimap<StringStringgetExtraResponseHeaders()

Returns the extra response headers that should be attached.

getGzipSupport

public int getGzipSupport()

Returns the level of gzip support the server should provide for this resource.

getHttpMethod

@DataSpec.HttpMethod
public int getHttpMethod()

The HTTP method that should be used to request the resource.

getPath

public String getPath()

Returns the path this resource is available at.

getRequestBody

public byte[] getRequestBody()

The body that should be included in a request for the resource.

getRequestHeaders

public ImmutableListMultimap<StringStringgetRequestHeaders()

The headers that should be included in a request for the resource.

includesContentLengthInRangeResponses

public boolean includesContentLengthInRangeResponses()

Returns true if RFC 7233 HTTP 206 responses should include a Content-Length header.

resolvesToUnknownLength

public boolean resolvesToUnknownLength()

Returns true if the resource should resolve to an unknown length.

supportsRangeRequests

public boolean supportsRangeRequests()

Returns true if RFC 7233 range requests should be supported for this resource.