Java Code Examples for io.vertx.core.http.HttpClientResponse#getHeader()
The following examples show how to use
io.vertx.core.http.HttpClientResponse#getHeader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestReadStreamPart.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void constructFromHttpClientResponse_noContentType(@Mocked HttpClientResponse httpClientResponse) { new Expectations() { { httpClientResponse.getHeader(HttpHeaders.CONTENT_DISPOSITION); result = "xx;filename=name.txt"; httpClientResponse.getHeader(HttpHeaders.CONTENT_TYPE); result = null; } }; part = new ReadStreamPart(context, httpClientResponse); Assert.assertEquals("name.txt", part.getSubmittedFileName()); Assert.assertEquals("text/plain", part.getContentType()); }
Example 2
Source File: TestReadStreamPart.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
@Test public void constructFromHttpClientResponse_hasContentType(@Mocked HttpClientResponse httpClientResponse) { new Expectations() { { httpClientResponse.getHeader(HttpHeaders.CONTENT_DISPOSITION); result = "xx;filename=name.txt"; httpClientResponse.getHeader(HttpHeaders.CONTENT_TYPE); result = "type"; } }; part = new ReadStreamPart(context, httpClientResponse); Assert.assertEquals("name.txt", part.getSubmittedFileName()); Assert.assertEquals("type", part.getContentType()); }
Example 3
Source File: RemoteFileSyncer.java From prebid-server-java with Apache License 2.0 | 5 votes |
private void checkNewVersion(HttpClientResponse response, Promise<Boolean> isNeedToUpdate) { final String contentLengthParameter = response.getHeader(HttpHeaders.CONTENT_LENGTH); if (StringUtils.isNumeric(contentLengthParameter) && !contentLengthParameter.equals("0")) { final long contentLength = Long.parseLong(contentLengthParameter); fileSystem.props(saveFilePath, filePropsResult -> { if (filePropsResult.succeeded()) { isNeedToUpdate.complete(filePropsResult.result().size() != contentLength); } else { isNeedToUpdate.fail(filePropsResult.cause()); } }); } else { isNeedToUpdate.fail(String.format("ContentLength is invalid: %s", contentLengthParameter)); } }
Example 4
Source File: ReadStreamPart.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
public ReadStreamPart(Context context, HttpClientResponse httpClientResponse) { this(context, (ReadStream<Buffer>) httpClientResponse); setSubmittedFileName( HttpUtils.parseFileNameFromHeaderValue(httpClientResponse.getHeader(HttpHeaders.CONTENT_DISPOSITION))); String contentType = httpClientResponse.getHeader(HttpHeaders.CONTENT_TYPE); if (StringUtils.isNotEmpty(contentType)) { this.contentType(contentType); } }
Example 5
Source File: ResponseContentTypeHandlerTest.java From vertx-web with Apache License 2.0 | 4 votes |
private String contentType(HttpClientResponse resp) { return resp.getHeader(CONTENT_TYPE); }
Example 6
Source File: ResponseContentTypeHandlerTest.java From vertx-web with Apache License 2.0 | 4 votes |
private Integer contentLength(HttpClientResponse resp) { String header = resp.getHeader(CONTENT_LENGTH); return header == null ? null : Integer.parseInt(header); }