Home | History | Annotate | Download | only in mockwebserver
      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.google.mockwebserver;
     18 
     19 /**
     20  * What should be done with the incoming socket.
     21  */
     22 public enum SocketPolicy {
     23 
     24     /**
     25      * Keep the socket open after the response. This is the default HTTP/1.1
     26      * behavior.
     27      */
     28     KEEP_OPEN,
     29 
     30     /**
     31      * Close the socket after the response. This is the default HTTP/1.0
     32      * behavior.
     33      */
     34     DISCONNECT_AT_END,
     35 
     36     /**
     37      * Wrap the socket with SSL at the completion of this request/response
     38      * pair. Used for CONNECT messages to tunnel SSL over an HTTP proxy.
     39      */
     40     UPGRADE_TO_SSL_AT_END,
     41 
     42     /**
     43      * Request immediate close of connection without even reading the
     44      * request.
     45      *
     46      * <p>Use to simulate the real life case of losing connection
     47      * because of bugger SSL server close connection when it seems
     48      * something like a compression method or TLS extension it doesn't
     49      * understand, instead of simply ignoring it like it should.
     50      */
     51     DISCONNECT_AT_START,
     52 
     53     /**
     54      * Request immediate close of connection after reading the entire
     55      * request (and before any response is sent).
     56      */
     57     DISCONNECT_AFTER_READING_REQUEST,
     58 
     59     /**
     60      * Don't trust the client during the SSL handshake.
     61      */
     62     FAIL_HANDSHAKE,
     63 
     64     /**
     65      * Shutdown the socket input after sending the response. For testing bad
     66      * behavior.
     67      */
     68     SHUTDOWN_INPUT_AT_END,
     69 
     70     /**
     71      * Shutdown the socket output after sending the response. For testing bad
     72      * behavior.
     73      */
     74     SHUTDOWN_OUTPUT_AT_END
     75 }
     76