List of usage examples for io.netty.handler.codec.http HttpHeaders getHeader
@Deprecated public static String getHeader(HttpMessage message, CharSequence name)
From source file:com.barchart.http.server.PooledServerRequest.java
License:BSD License
@Override public String getContentType() { return HttpHeaders.getHeader(nettyRequest, HttpHeaders.Names.CONTENT_TYPE); }
From source file:com.bloom.zerofs.rest.NettyResponseChannel.java
License:Open Source License
@Override public Object getHeader(String headerName) { HttpResponse response = finalResponseMetadata; if (response == null) { response = responseMetadata;/*from ww w.j a va 2 s . com*/ } return HttpHeaders.getHeader(response, headerName); }
From source file:com.cu.http.container.core.adaptor.NettyServletRequest.java
License:Apache License
@Override public String getHeader(String name) { return HttpHeaders.getHeader(this.originalRequest, name); }
From source file:com.cu.http.container.core.adaptor.NettyServletRequest.java
License:Apache License
@Override public String getContentType() { return HttpHeaders.getHeader(this.originalRequest, HttpHeaders.Names.CONTENT_TYPE); }
From source file:com.cu.http.container.core.adaptor.NettyServletRequest.java
License:Apache License
@SuppressWarnings("rawtypes") @Override//from w w w .j a va 2 s . co m public Enumeration getLocales() { Collection<Locale> locales = Utils.parseAcceptLanguageHeader( HttpHeaders.getHeader(this.originalRequest, HttpHeaders.Names.ACCEPT_LANGUAGE)); if (locales == null || locales.isEmpty()) { locales = new ArrayList<Locale>(); locales.add(Locale.getDefault()); } return Utils.enumeration(locales); }
From source file:com.e2e.management.HttpSocketHandler.java
License:Apache License
@Override public void messageReceived(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { String upgrade = HttpHeaders.getHeader(((FullHttpRequest) request), Names.UPGRADE); if (!Values.WEBSOCKET.toString().toLowerCase().equals(upgrade)) { handleHttpFileRequest(ctx, (FullHttpRequest) request); } else {/*from w w w . j a va2 s. c om*/ handleHttpRequest(ctx, (FullHttpRequest) request); } }
From source file:com.github.ambry.admin.AdminIntegrationTest.java
License:Open Source License
/** * Tests the {@link AdminBlobStorageService#ECHO} operation. Checks to see that the echo matches input text. * @throws ExecutionException// w w w. j ava2 s. c o m * @throws InterruptedException * @throws JSONException */ @Test public void echoTest() throws ExecutionException, InterruptedException, JSONException { String inputText = "loremIpsum"; String uri = AdminBlobStorageService.ECHO + "?" + EchoHandler.TEXT_KEY + "=" + inputText; FullHttpRequest httpRequest = buildRequest(HttpMethod.GET, uri, null, null); Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected status", HttpResponseStatus.OK, response.getStatus()); assertEquals("Unexpected Content-Type", "application/json", HttpHeaders.getHeader(response, HttpHeaders.Names.CONTENT_TYPE)); ByteBuffer buffer = getContent(response, responseParts); String echoedText = new JSONObject(new String(buffer.array())).getString(EchoHandler.TEXT_KEY); assertEquals("Did not get expected response", inputText, echoedText); }
From source file:com.github.ambry.admin.AdminIntegrationTest.java
License:Open Source License
/** * Tests the {@link AdminBlobStorageService#GET_REPLICAS_FOR_BLOB_ID} operation. * <p/>// w w w . j ava 2 s . c om * For a random {@link PartitionId} in the {@link ClusterMap}, a {@link BlobId} is created. The string representation * is sent to the server as a part of request. The returned replica list is checked for equality against a locally * obtained replica list. * @throws ExecutionException * @throws InterruptedException * @throws JSONException */ @Test public void getReplicasForBlobIdTest() throws ExecutionException, InterruptedException, JSONException { List<PartitionId> partitionIds = CLUSTER_MAP.getWritablePartitionIds(); PartitionId partitionId = partitionIds.get(new Random().nextInt(partitionIds.size())); String originalReplicaStr = partitionId.getReplicaIds().toString().replace(", ", ","); BlobId blobId = new BlobId(partitionId); String uri = AdminBlobStorageService.GET_REPLICAS_FOR_BLOB_ID + "?" + GetReplicasForBlobIdHandler.BLOB_ID_KEY + "=" + blobId; FullHttpRequest httpRequest = buildRequest(HttpMethod.GET, uri, null, null); Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected status", HttpResponseStatus.OK, response.getStatus()); assertEquals("Unexpected Content-Type", "application/json", HttpHeaders.getHeader(response, HttpHeaders.Names.CONTENT_TYPE)); ByteBuffer buffer = getContent(response, responseParts); JSONObject responseObj = new JSONObject(new String(buffer.array())); String returnedReplicasStr = responseObj.getString(GetReplicasForBlobIdHandler.REPLICAS_KEY).replace("\"", ""); assertEquals("Returned response for the BlobId do no match with the replicas IDs of partition", originalReplicaStr, returnedReplicasStr); }
From source file:com.github.ambry.admin.AdminIntegrationTest.java
License:Open Source License
/** * Gets the headers of the blob with blob ID {@code blobId} and verifies them against what is expected. * @param blobId the blob ID of the blob to HEAD. * @param expectedHeaders the expected headers in the response. * @throws ExecutionException//from w w w . j av a 2s.co m * @throws InterruptedException */ private void getHeadAndVerify(String blobId, HttpHeaders expectedHeaders) throws ExecutionException, InterruptedException { FullHttpRequest httpRequest = buildRequest(HttpMethod.HEAD, blobId, null, null); Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); discardContent(responseParts, 1); assertEquals("Unexpected response status", HttpResponseStatus.OK, response.getStatus()); checkCommonGetHeadHeaders(response.headers(), expectedHeaders); assertEquals("Content-Length does not match blob size", Long.parseLong(expectedHeaders.get(RestUtils.Headers.BLOB_SIZE)), HttpHeaders.getContentLength(response)); assertEquals("Blob size does not match", expectedHeaders.get(RestUtils.Headers.BLOB_SIZE), HttpHeaders.getHeader(response, RestUtils.Headers.BLOB_SIZE)); assertEquals(RestUtils.Headers.SERVICE_ID + " does not match", expectedHeaders.get(RestUtils.Headers.SERVICE_ID), HttpHeaders.getHeader(response, RestUtils.Headers.SERVICE_ID)); assertEquals(RestUtils.Headers.PRIVATE + " does not match", expectedHeaders.get(RestUtils.Headers.PRIVATE), HttpHeaders.getHeader(response, RestUtils.Headers.PRIVATE)); assertEquals(RestUtils.Headers.AMBRY_CONTENT_TYPE + " does not match", expectedHeaders.get(RestUtils.Headers.AMBRY_CONTENT_TYPE), HttpHeaders.getHeader(response, RestUtils.Headers.AMBRY_CONTENT_TYPE)); assertTrue("No " + RestUtils.Headers.CREATION_TIME, HttpHeaders.getHeader(response, RestUtils.Headers.CREATION_TIME, null) != null); if (Long.parseLong(expectedHeaders.get(RestUtils.Headers.TTL)) != Utils.Infinite_Time) { assertEquals(RestUtils.Headers.TTL + " does not match", expectedHeaders.get(RestUtils.Headers.TTL), HttpHeaders.getHeader(response, RestUtils.Headers.TTL)); } if (expectedHeaders.contains(RestUtils.Headers.OWNER_ID)) { assertEquals(RestUtils.Headers.OWNER_ID + " does not match", expectedHeaders.get(RestUtils.Headers.OWNER_ID), HttpHeaders.getHeader(response, RestUtils.Headers.OWNER_ID)); } }
From source file:com.github.ambry.frontend.FrontendIntegrationTest.java
License:Open Source License
/** * Gets the headers of the blob with blob ID {@code blobId} and verifies them against what is expected. * @param blobId the blob ID of the blob to HEAD. * @param expectedHeaders the expected headers in the response. * @throws ExecutionException/* w w w. j av a 2 s . co m*/ * @throws InterruptedException */ private void getHeadAndVerify(String blobId, HttpHeaders expectedHeaders) throws ExecutionException, InterruptedException { FullHttpRequest httpRequest = buildRequest(HttpMethod.HEAD, blobId, null, null); Queue<HttpObject> responseParts = nettyClient.sendRequest(httpRequest, null, null).get(); HttpResponse response = (HttpResponse) responseParts.poll(); assertEquals("Unexpected response status", HttpResponseStatus.OK, response.getStatus()); checkCommonGetHeadHeaders(response.headers()); assertEquals(RestUtils.Headers.CONTENT_LENGTH + " does not match " + RestUtils.Headers.BLOB_SIZE, Long.parseLong(expectedHeaders.get(RestUtils.Headers.BLOB_SIZE)), HttpHeaders.getContentLength(response)); assertEquals(RestUtils.Headers.CONTENT_TYPE + " does not match " + RestUtils.Headers.AMBRY_CONTENT_TYPE, expectedHeaders.get(RestUtils.Headers.AMBRY_CONTENT_TYPE), HttpHeaders.getHeader(response, HttpHeaders.Names.CONTENT_TYPE)); verifyBlobProperties(expectedHeaders, response); discardContent(responseParts, 1); assertTrue("Channel should be active", HttpHeaders.isKeepAlive(response)); }