An immutable request to an http server.
| 34 | |
| 35 | /** An immutable request to an http server. */ |
| 36 | public final class Request implements Serializable { |
| 37 | |
| 38 | public enum HttpMethod { |
| 39 | GET, |
| 40 | HEAD, |
| 41 | POST(true), |
| 42 | PUT(true), |
| 43 | DELETE, |
| 44 | CONNECT, |
| 45 | OPTIONS, |
| 46 | TRACE, |
| 47 | PATCH(true); |
| 48 | |
| 49 | private final boolean withBody; |
| 50 | |
| 51 | HttpMethod() { |
| 52 | this(false); |
| 53 | } |
| 54 | |
| 55 | HttpMethod(boolean withBody) { |
| 56 | this.withBody = withBody; |
| 57 | } |
| 58 | |
| 59 | public boolean isWithBody() { |
| 60 | return this.withBody; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | public enum ProtocolVersion { |
| 65 | HTTP_1_0("HTTP/1.0"), |
| 66 | HTTP_1_1("HTTP/1.1"), |
| 67 | HTTP_2("HTTP/2.0"), |
| 68 | MOCK; |
| 69 | |
| 70 | final String protocolVersion; |
| 71 | |
| 72 | ProtocolVersion() { |
| 73 | protocolVersion = name(); |
| 74 | } |
| 75 | |
| 76 | ProtocolVersion(String protocolVersion) { |
| 77 | this.protocolVersion = protocolVersion; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public String toString() { |
| 82 | return protocolVersion; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * No parameters can be null except {@code body} and {@code charset}. All parameters must be |
| 88 | * effectively immutable, via safe copies, not mutating or otherwise. |
| 89 | * |
| 90 | * @deprecated {@link #create(HttpMethod, String, Map, byte[], Charset)} |
| 91 | */ |
| 92 | @Deprecated |
| 93 | public static Request create( |
nothing calls this directly
no outgoing calls
no test coverage detected