• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.squareup.okhttp.mockwebserver;
18 
19 /** What should be done with the incoming socket. */
20 public enum SocketPolicy {
21 
22   /**
23    * Keep the socket open after the response. This is the default HTTP/1.1
24    * behavior.
25    */
26   KEEP_OPEN,
27 
28   /**
29    * Close the socket after the response. This is the default HTTP/1.0
30    * behavior.
31    */
32   DISCONNECT_AT_END,
33 
34   /**
35    * Wrap the socket with SSL at the completion of this request/response pair.
36    * Used for CONNECT messages to tunnel SSL over an HTTP proxy.
37    */
38   UPGRADE_TO_SSL_AT_END,
39 
40   /**
41    * Request immediate close of connection without even reading the request. Use
42    * to simulate buggy SSL servers closing connections in response to
43    * unrecognized TLS extensions.
44    */
45   DISCONNECT_AT_START,
46 
47   /**
48    * Close connection after reading the request but before writing the response.
49    * Use this to simulate late connection pool failures.
50    */
51   DISCONNECT_AFTER_REQUEST,
52 
53   /** Close connection after reading half of the request body (if present). */
54   DISCONNECT_DURING_REQUEST_BODY,
55 
56   /** Close connection after writing half of the response body (if present). */
57   DISCONNECT_DURING_RESPONSE_BODY,
58 
59   /** Don't trust the client during the SSL handshake. */
60   FAIL_HANDSHAKE,
61 
62   /**
63    * Shutdown the socket input after sending the response. For testing bad
64    * behavior.
65    */
66   SHUTDOWN_INPUT_AT_END,
67 
68   /**
69    * Shutdown the socket output after sending the response. For testing bad
70    * behavior.
71    */
72   SHUTDOWN_OUTPUT_AT_END,
73 
74   /**
75    * Don't respond to the request but keep the socket open. For testing
76    * read response header timeout issue.
77    */
78   NO_RESPONSE
79 }
80