public enum SocketPolicy extends Enum<SocketPolicy>
Be careful when using values like DISCONNECT_AT_END
, SHUTDOWN_INPUT_AT_END
and SHUTDOWN_OUTPUT_AT_END
that close a socket after a response, and where there are
follow-up requests. The client is unblocked and free to continue as soon as it has received the
entire response body. If and when the client makes a subsequent request using a pooled socket the
server may not have had time to close the socket. The socket will be closed at an indeterminate
point before or during the second request. It may be closed after client has started sending the
request body. If a request body is not retryable then the client may fail the request, making
client behavior non-deterministic. Add delays in the client to improve the chances that the
server has closed the socket before follow up requests are made.
Enum Constant and Description |
---|
CONTINUE_ALWAYS
Transmit a
HTTP/1.1 100 Continue response before reading the HTTP request body even
if the client does not send the header Expect: 100-continue in its request. |
DISCONNECT_AFTER_REQUEST
Close connection after reading the request but before writing the response.
|
DISCONNECT_AT_END
Close the socket after the response.
|
DISCONNECT_AT_START
Request immediate close of connection without even reading the request.
|
DISCONNECT_DURING_REQUEST_BODY
Close connection after reading half of the request body (if present).
|
DISCONNECT_DURING_RESPONSE_BODY
Close connection after writing half of the response body (if present).
|
EXPECT_CONTINUE
Transmit a
HTTP/1.1 100 Continue response before reading the HTTP request body. |
FAIL_HANDSHAKE
Don't trust the client during the SSL handshake.
|
KEEP_OPEN
Keep the socket open after the response.
|
NO_RESPONSE
Read the request but don't respond to it.
|
RESET_STREAM_AT_START
Fail HTTP/2 requests without processing them by sending an HTTP/2 error code.
|
SHUTDOWN_INPUT_AT_END
Shutdown the socket input after sending the response.
|
SHUTDOWN_OUTPUT_AT_END
Shutdown the socket output after sending the response.
|
SHUTDOWN_SERVER_AFTER_RESPONSE
Shutdown
MockWebServer after writing response. |
STALL_SOCKET_AT_START
After accepting the connection and doing TLS (if configured) don't do HTTP/1.1 or HTTP/2
framing.
|
UPGRADE_TO_SSL_AT_END
Wrap the socket with SSL at the completion of this request/response pair.
|
Modifier and Type | Method and Description |
---|---|
static SocketPolicy |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SocketPolicy[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SocketPolicy SHUTDOWN_SERVER_AFTER_RESPONSE
MockWebServer
after writing response.public static final SocketPolicy KEEP_OPEN
public static final SocketPolicy DISCONNECT_AT_END
See SocketPolicy
for reasons why this can cause test flakiness and how to avoid it.
public static final SocketPolicy UPGRADE_TO_SSL_AT_END
public static final SocketPolicy DISCONNECT_AT_START
public static final SocketPolicy DISCONNECT_AFTER_REQUEST
public static final SocketPolicy DISCONNECT_DURING_REQUEST_BODY
public static final SocketPolicy DISCONNECT_DURING_RESPONSE_BODY
public static final SocketPolicy FAIL_HANDSHAKE
public static final SocketPolicy SHUTDOWN_INPUT_AT_END
See SocketPolicy
for reasons why this can cause test flakiness and how to avoid it.
public static final SocketPolicy SHUTDOWN_OUTPUT_AT_END
See SocketPolicy
for reasons why this can cause test flakiness and how to avoid it.
public static final SocketPolicy STALL_SOCKET_AT_START
public static final SocketPolicy NO_RESPONSE
public static final SocketPolicy RESET_STREAM_AT_START
public static final SocketPolicy EXPECT_CONTINUE
HTTP/1.1 100 Continue
response before reading the HTTP request body.
Typically this response is sent when a client makes a request with the header Expect: 100-continue
.public static final SocketPolicy CONTINUE_ALWAYS
HTTP/1.1 100 Continue
response before reading the HTTP request body even
if the client does not send the header Expect: 100-continue
in its request.public static SocketPolicy[] values()
for (SocketPolicy c : SocketPolicy.values()) System.out.println(c);
public static SocketPolicy valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullCopyright © 2019. All rights reserved.