HurlStack extends AbstractHttpStack { void setConnectionParametersForRequest(HttpURLConnection connection, Request<?> request) throws IOException { switch (request.getMethod()) { case Method.GET: break; case Method.DELETE: connection.setRequestMethod("DELETE"); break; case Method.POST: connection.setRequestMethod("POST"); addBodyIfExists(connection, request); break; case Method.PUT: connection.setRequestMethod("PUT"); addBodyIfExists(connection, request); break; case Method.HEAD: connection.setRequestMethod("HEAD"); break; case Method.OPTIONS: connection.setRequestMethod("OPTIONS"); break; case Method.TRACE: connection.setRequestMethod("TRACE"); break; case Method.PATCH: connection.setRequestMethod("PATCH"); addBodyIfExists(connection, request); break; default: connection.setRequestMethod(request.getMethod()); addBodyIfExists(connection, request); break; } } HurlStack();  HurlStack(UrlRewriter urlRewriter);  HurlStack(UrlRewriter urlRewriter, SSLSocketFactory sslSocketFactory); HurlStack setFixedLengthStreamingMode(boolean enabled); @Override NetworkResponse performRequest(Request<?> request, Headers
            additionalHeaders, ByteArrayPool byteArrayPool);  }
@Test public void connectionForGetRequest() throws Exception { TestRequest.Get request = new TestRequest.Get(); assertEquals(request.getMethod(), Method.GET); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("GET", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForPostRequest() throws Exception { TestRequest.Post request = new TestRequest.Post(); assertEquals(request.getMethod(), Method.POST); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("POST", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForPostWithBodyRequest() throws Exception { TestRequest.PostWithBody request = new TestRequest.PostWithBody(); assertEquals(request.getMethod(), Method.POST); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("POST", mockConnection.getRequestMethod()); assertTrue(mockConnection.getDoOutput()); }
@Test public void connectionForPutRequest() throws Exception { TestRequest.Put request = new TestRequest.Put(); assertEquals(request.getMethod(), Method.PUT); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("PUT", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForPutWithBodyRequest() throws Exception { TestRequest.PutWithBody request = new TestRequest.PutWithBody(); assertEquals(request.getMethod(), Method.PUT); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("PUT", mockConnection.getRequestMethod()); assertTrue(mockConnection.getDoOutput()); }
@Test public void connectionForDeleteRequest() throws Exception { TestRequest.Delete request = new TestRequest.Delete(); assertEquals(request.getMethod(), Method.DELETE); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("DELETE", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForHeadRequest() throws Exception { TestRequest.Head request = new TestRequest.Head(); assertEquals(request.getMethod(), Method.HEAD); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("HEAD", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForOptionsRequest() throws Exception { TestRequest.Options request = new TestRequest.Options(); assertEquals(request.getMethod(), Method.OPTIONS); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("OPTIONS", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForTraceRequest() throws Exception { TestRequest.Trace request = new TestRequest.Trace(); assertEquals(request.getMethod(), Method.TRACE); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("TRACE", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForPatchRequest() throws Exception { TestRequest.Patch request = new TestRequest.Patch(); assertEquals(request.getMethod(), Method.PATCH); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("PATCH", mockConnection.getRequestMethod()); assertFalse(mockConnection.getDoOutput()); }
@Test public void connectionForPatchWithBodyRequest() throws Exception { TestRequest.PatchWithBody request = new TestRequest.PatchWithBody(); assertEquals(request.getMethod(), Method.PATCH); hurlStack.setConnectionParametersForRequest(mockConnection, request); assertEquals("PATCH", mockConnection.getRequestMethod()); assertTrue(mockConnection.getDoOutput()); }