List of usage examples for io.netty.handler.codec.http HttpHeaders getDateHeader
@Deprecated public static Date getDateHeader(HttpMessage message, CharSequence name, Date defaultValue)
From source file:com.github.ambry.admin.AdminIntegrationTest.java
License:Open Source License
/** * Posts a blob with the given {@code headers} and {@code content}. * @param headers the headers required.// www . ja v a2 s .co m * @param content the content of the blob. * @return the blob ID of the blob. * @throws ExecutionException * @throws InterruptedException */ private String postBlobAndVerify(HttpHeaders headers, ByteBuffer content) throws ExecutionException, InterruptedException { FullHttpRequest httpRequest = buildRequest(HttpMethod.POST, "/", headers, content); Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); discardContent(responseParts, 1); assertEquals("Unexpected response status", HttpResponseStatus.CREATED, response.getStatus()); assertTrue("No Date header", HttpHeaders.getDateHeader(response, HttpHeaders.Names.DATE, null) != null); assertTrue("No " + RestUtils.Headers.CREATION_TIME, HttpHeaders.getHeader(response, RestUtils.Headers.CREATION_TIME, null) != null); assertEquals("Content-Length is not 0", 0, HttpHeaders.getContentLength(response)); String blobId = HttpHeaders.getHeader(response, HttpHeaders.Names.LOCATION, null); if (blobId == null) { fail("postBlobAndVerify did not return a blob ID"); } return blobId; }
From source file:com.github.ambry.admin.AdminIntegrationTest.java
License:Open Source License
/** * Verifies that a request returns the right response code once the blob has been deleted. * @param httpRequest the {@link FullHttpRequest} to send to the server. * @param expectedStatusCode the expected {@link HttpResponseStatus}. * @throws ExecutionException//from w w w . ja va2 s. co m * @throws InterruptedException */ private void verifyDeleted(FullHttpRequest httpRequest, HttpResponseStatus expectedStatusCode) throws ExecutionException, InterruptedException { Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); discardContent(responseParts, 1); assertEquals("Unexpected response status", expectedStatusCode, response.getStatus()); assertTrue("No Date header", HttpHeaders.getDateHeader(response, HttpHeaders.Names.DATE, null) != null); }
From source file:com.github.ambry.frontend.FrontendIntegrationTest.java
License:Open Source License
/** * Posts a blob with the given {@code headers} and {@code content}. * @param headers the headers required.//from w w w.ja v a 2s . c om * @param content the content of the blob. * @return the blob ID of the blob. * @throws ExecutionException * @throws InterruptedException */ private String postBlobAndVerify(HttpHeaders headers, ByteBuffer content) throws ExecutionException, InterruptedException { FullHttpRequest httpRequest = buildRequest(HttpMethod.POST, "/", headers, content); Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected response status", HttpResponseStatus.CREATED, response.getStatus()); assertTrue("No Date header", HttpHeaders.getDateHeader(response, HttpHeaders.Names.DATE, null) != null); assertTrue("No " + RestUtils.Headers.CREATION_TIME, HttpHeaders.getHeader(response, RestUtils.Headers.CREATION_TIME, null) != null); assertEquals("Content-Length is not 0", 0, HttpHeaders.getContentLength(response)); String blobId = HttpHeaders.getHeader(response, HttpHeaders.Names.LOCATION, null); if (blobId == null) { fail("postBlobAndVerify did not return a blob ID"); } discardContent(responseParts, 1); assertTrue("Channel should be active", HttpHeaders.isKeepAlive(response)); return blobId; }
From source file:com.github.ambry.frontend.FrontendIntegrationTest.java
License:Open Source License
/** * Verifies that a request returns the right response code once the blob has been deleted. * @param httpRequest the {@link FullHttpRequest} to send to the server. * @param expectedStatusCode the expected {@link HttpResponseStatus}. * @throws ExecutionException/*from w ww .j a va2s.co m*/ * @throws InterruptedException */ private void verifyDeleted(FullHttpRequest httpRequest, HttpResponseStatus expectedStatusCode) throws ExecutionException, InterruptedException { Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected response status", expectedStatusCode, response.getStatus()); assertTrue("No Date header", HttpHeaders.getDateHeader(response, HttpHeaders.Names.DATE, null) != null); discardContent(responseParts, 1); assertTrue("Channel should be active", HttpHeaders.isKeepAlive(response)); }
From source file:com.github.ambry.frontend.FrontendIntegrationTest.java
License:Open Source License
/** * Posts a blob with the given {@code headers} and {@code content}. * @param headers the headers required./* ww w . jav a2 s .co m*/ * @param content the content of the blob. * @param usermetadata the {@link ByteBuffer} that represents user metadata * @return the blob ID of the blob. * @throws Exception */ private String multipartPostBlobAndVerify(HttpHeaders headers, ByteBuffer content, ByteBuffer usermetadata) throws Exception { HttpRequest httpRequest = RestTestUtils.createRequest(HttpMethod.POST, "/", headers); HttpPostRequestEncoder encoder = createEncoder(httpRequest, content, usermetadata); Queue<HttpObject> responseParts = nettyClient.sendRequest(encoder.finalizeRequest(), encoder, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected response status", HttpResponseStatus.CREATED, response.getStatus()); assertTrue("No Date header", HttpHeaders.getDateHeader(response, HttpHeaders.Names.DATE, null) != null); assertTrue("No " + RestUtils.Headers.CREATION_TIME, HttpHeaders.getHeader(response, RestUtils.Headers.CREATION_TIME, null) != null); assertEquals("Content-Length is not 0", 0, HttpHeaders.getContentLength(response)); String blobId = HttpHeaders.getHeader(response, HttpHeaders.Names.LOCATION, null); if (blobId == null) { fail("postBlobAndVerify did not return a blob ID"); } discardContent(responseParts, 1); assertTrue("Channel should be active", HttpHeaders.isKeepAlive(response)); return blobId; }
From source file:io.reactivex.netty.protocol.http.client.HttpRequestHeaders.java
License:Apache License
public Date getDateHeader(CharSequence name, Date defaultValue) { return HttpHeaders.getDateHeader(nettyRequest, name, defaultValue); }
From source file:io.reactivex.netty.protocol.http.client.HttpRequestHeaders.java
License:Apache License
public Date getDateHeader(String name, Date defaultValue) { return HttpHeaders.getDateHeader(nettyRequest, name, defaultValue); }
From source file:io.reactivex.netty.protocol.http.client.HttpResponseHeaders.java
License:Apache License
public Date getDateHeader(CharSequence name, Date defaultValue) { return HttpHeaders.getDateHeader(nettyResponse, name, defaultValue); }
From source file:io.reactivex.netty.protocol.http.client.HttpResponseHeaders.java
License:Apache License
public Date getDateHeader(String name, Date defaultValue) { return HttpHeaders.getDateHeader(nettyResponse, name, defaultValue); }
From source file:org.ireland.jnetty.http.HttpServletRequestImpl.java
License:Open Source License
@Override // OK/*w w w. j a v a 2 s .co m*/ public long getDateHeader(String name) { Date date = HttpHeaders.getDateHeader(request, name, null); return (date == null) ? -1 : date.getTime(); }