APISonar


io.netty.handler.codec.http.HttpHeaderNames.DATE

> io > netty > handler > codec > http > HttpHeaderNames > DATE
io APIs netty APIs handler APIs codec APIs http APIs HttpHeaderNames APIs DATE APIs

Example 1
private static void setDateHeader(FullHttpResponse response) {
        SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
        dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));

        Calendar time = new GregorianCalendar();
        response.headers().set(HttpHeaderNames.DATE, dateFormatter.format(time.getTime()));
    }
Example 2
public void handle(Context ctx) {
        MutableHeaders headers = ctx.getResponse().getHeaders();
        headers.set(HttpHeaderNames.DATE, dateHelper.getDate());
        headers.set(SERVER, RATPACK);
        ctx.next();
    }
Example 3
private HttpRequest createRequestWithHeaders(HttpMethod httpMethod, String uri) {
    long currentTime = System.currentTimeMillis();
    HttpRequest request = RestTestUtils.createRequest(httpMethod, uri, null);
    request.headers().set(HttpHeaderNames.CONTENT_TYPE, "dummy/content-type");
    request.headers().set(HttpHeaderNames.CONTENT_LENGTH, 100);
    request.headers().set(HttpHeaderNames.LOCATION, "dummyLocation");
    request.headers().set(HttpHeaderNames.LAST_MODIFIED, new Date(currentTime));
    request.headers().set(HttpHeaderNames.EXPIRES, new Date(currentTime + 1));
    request.headers().set(HttpHeaderNames.CACHE_CONTROL, "dummyCacheControl");
    request.headers().set(HttpHeaderNames.PRAGMA, "dummyPragma");
    request.headers().set(HttpHeaderNames.DATE, new Date(currentTime + 2));
    request.headers().set(MockNettyMessageProcessor.CUSTOM_HEADER_NAME, "customHeaderValue");
    return request;
  }
Example 4
private void checkCommonGetHeadHeaders(HttpHeaders receivedHeaders) {
    assertTrue("No Date header", receivedHeaders.get(HttpHeaderNames.DATE) != null);
    assertTrue("No Last-Modified header", receivedHeaders.get(HttpHeaderNames.LAST_MODIFIED) != null);
  }
Example 5
public void optionsTest() throws Exception {
    FullHttpRequest httpRequest = buildRequest(HttpMethod.OPTIONS, "", null, null);
    ResponseParts responseParts = nettyClient.sendRequest(httpRequest, null, null).get();
    HttpResponse response = getHttpResponse(responseParts);
    assertEquals("Unexpected response status", HttpResponseStatus.OK, response.status());
    assertTrue("No Date header", response.headers().getTimeMillis(HttpHeaderNames.DATE, -1) != -1);
    assertEquals("Content-Length is not 0", 0, HttpUtil.getContentLength(response));
    assertEquals("Unexpected value for " + HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS,
        FRONTEND_CONFIG.optionsAllowMethods, response.headers().get(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS));
    assertEquals("Unexpected value for " + HttpHeaderNames.ACCESS_CONTROL_MAX_AGE,
        FRONTEND_CONFIG.optionsValiditySeconds,
        Long.parseLong(response.headers().get(HttpHeaderNames.ACCESS_CONTROL_MAX_AGE)));
    verifyTrackingHeaders(response);
  }
Example 6
public void defaultPreflightResponseHeaders() {
        final CorsConfig cors = forAnyOrigin().build();
        assertThat(cors.preflightResponseHeaders().get(HttpHeaderNames.DATE), is(notNullValue()));
        assertThat(cors.preflightResponseHeaders().get(HttpHeaderNames.CONTENT_LENGTH), is("0"));
    }