Package org.mockserver.model
Class ConnectionOptions
- java.lang.Object
-
- org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
-
- org.mockserver.model.ObjectWithJsonToString
-
- org.mockserver.model.ConnectionOptions
-
public class ConnectionOptions extends ObjectWithJsonToString
- Author:
- jamesdbloom
-
-
Constructor Summary
Constructors Constructor Description ConnectionOptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ConnectionOptionsconnectionOptions()DelaygetChunkDelay()IntegergetChunkSize()BooleangetCloseSocket()DelaygetCloseSocketDelay()IntegergetContentLengthHeaderOverride()BooleangetKeepAliveOverride()BooleangetSuppressConnectionHeader()BooleangetSuppressContentLengthHeader()ConnectionOptionswithChunkDelay(Delay chunkDelay)Specifies the delay between sending each chunk of a chunked response.ConnectionOptionswithChunkSize(Integer chunkSize)Specifies the size of chunks in a response:ConnectionOptionswithCloseSocket(Boolean closeSocket)Override whether the socket is closed after a response is sent: if true the socket will always be closed, if false the socket will never be closed, if not set the socket will be closed unless the request received is HTTP 1.1 and contains a "Connection" header with a value of "keep-alive"ConnectionOptionswithCloseSocketDelay(Delay closeSocketDelay)Override how long to delay before closing socket, this value is ignored if socket isn't going to be closedConnectionOptionswithContentLengthHeaderOverride(Integer contentLengthHeaderOverride)Override the "Content-Length" header with the specified amount, if not set the "Content-Length" header will have a value determined by the length of the bodyConnectionOptionswithKeepAliveOverride(Boolean keepAliveOverride)Override the "Connection" header: if true the "Connection" header is specified with a value of "keep-alive" if false the "Connection" header is specified with a value of "close" if not set the "Connection" header will have a a value of "close" unless the request received is HTTP 1.1 and contains a "Connection" header with a value of "keep-alive"ConnectionOptionswithSuppressConnectionHeader(Boolean suppressConnectionHeader)Prevent a "Connection" header from being added to the responseConnectionOptionswithSuppressContentLengthHeader(Boolean suppressContentLengthHeader)Prevent a "Content-Length" header from being added to the response-
Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toString
-
Methods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
equals, fieldsExcludedFromEqualsAndHashCode, hashCode
-
-
-
-
Method Detail
-
connectionOptions
public static ConnectionOptions connectionOptions()
-
withSuppressContentLengthHeader
public ConnectionOptions withSuppressContentLengthHeader(Boolean suppressContentLengthHeader)
Prevent a "Content-Length" header from being added to the response- Parameters:
suppressContentLengthHeader- if true no "Content-Length" header will be added to the response
-
getSuppressContentLengthHeader
public Boolean getSuppressContentLengthHeader()
-
withContentLengthHeaderOverride
public ConnectionOptions withContentLengthHeaderOverride(Integer contentLengthHeaderOverride)
Override the "Content-Length" header with the specified amount, if not set the "Content-Length" header will have a value determined by the length of the body- Parameters:
contentLengthHeaderOverride- the value to use for the "Content-Length" header
-
getContentLengthHeaderOverride
public Integer getContentLengthHeaderOverride()
-
withSuppressConnectionHeader
public ConnectionOptions withSuppressConnectionHeader(Boolean suppressConnectionHeader)
Prevent a "Connection" header from being added to the response- Parameters:
suppressConnectionHeader- if true no "Connection" header will be added to the response
-
getSuppressConnectionHeader
public Boolean getSuppressConnectionHeader()
-
withChunkSize
public ConnectionOptions withChunkSize(Integer chunkSize)
Specifies the size of chunks in a response:If null (the default value), zero or negative then response will not be chunked If positive and non-null the response will have "Transfer-Encoding: chunked" header and will be chunked into chunks of the size specified (as long as the body is large enough)
- Parameters:
chunkSize- the size of response chunks, if null response will not be chunked
-
getChunkSize
public Integer getChunkSize()
-
withChunkDelay
public ConnectionOptions withChunkDelay(Delay chunkDelay)
Specifies the delay between sending each chunk of a chunked response. This simulates slow or degraded network conditions by dribbling the response body over time. Only applies when chunkSize is set to a positive value.- Parameters:
chunkDelay- the delay to apply between each chunk
-
getChunkDelay
public Delay getChunkDelay()
-
withKeepAliveOverride
public ConnectionOptions withKeepAliveOverride(Boolean keepAliveOverride)
Override the "Connection" header: if true the "Connection" header is specified with a value of "keep-alive" if false the "Connection" header is specified with a value of "close" if not set the "Connection" header will have a a value of "close" unless the request received is HTTP 1.1 and contains a "Connection" header with a value of "keep-alive"- Parameters:
keepAliveOverride- if true "keep-alive" is used if false "close" is used for the "Connection" header
-
getKeepAliveOverride
public Boolean getKeepAliveOverride()
-
withCloseSocket
public ConnectionOptions withCloseSocket(Boolean closeSocket)
Override whether the socket is closed after a response is sent: if true the socket will always be closed, if false the socket will never be closed, if not set the socket will be closed unless the request received is HTTP 1.1 and contains a "Connection" header with a value of "keep-alive"- Parameters:
closeSocket- set whether the socket is closed after a response is sent
-
getCloseSocket
public Boolean getCloseSocket()
-
withCloseSocketDelay
public ConnectionOptions withCloseSocketDelay(Delay closeSocketDelay)
Override how long to delay before closing socket, this value is ignored if socket isn't going to be closed- Parameters:
closeSocketDelay- set delay before closing socket
-
getCloseSocketDelay
public Delay getCloseSocketDelay()
-
-