APISonar


javax.ws.rs.core.HttpHeaders.DATE

> javax > ws > rs > core > HttpHeaders > DATE
javax APIs ws APIs rs APIs core APIs HttpHeaders APIs DATE APIs

Example 1
public Date getDate() {
        return singleHeader(HttpHeaders.DATE, new Function<String, Date>() {
            @Override
            public Date apply(String input) {
                try {
                    return HttpHeaderReader.readDate(input);
                } catch (ParseException ex) {
                    throw new ProcessingException(ex);
                }
            }
        }, false);
    }
Example 2
public Date getDate()
   {
      Object d = metadata.getFirst(HttpHeaders.DATE);
      if (d == null) return null;
      if (d instanceof Date) return (Date) d;
      return DateUtil.parseDate(d.toString());
   }
Example 3
public void testDate() throws URISyntaxException, ParseException {
        OutboundMessageContext r = new OutboundMessageContext();
        r.getHeaders().add(HttpHeaders.DATE, "Tue, 29 Jan 2002 22:14:02 -0500");
        SimpleDateFormat f = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
        Date date = f.parse("Tue, 29 Jan 2002 22:14:02 -0500");
        assertEquals(r.getDate(), date);
    }
Example 4
public static Response getResponse(UserArgs args, int statusCode,
                                     String payload) {
    String date = DATE_FORMAT.get().format(new Date(Time.now()));
    return Response.ok(payload)
        .header(Header.OZONE_SERVER_NAME, args.getHostName())
        .header(Header.OZONE_REQUEST_ID, args.getRequestID())
        .header(HttpHeaders.DATE, date).status(statusCode).build();
  }
Example 5
private void setResponseDate(MultivaluedMap<String, Object> headers, boolean firstTry) {
        if (!firstTry) {
            return;
        }
        SimpleDateFormat format = HttpUtils.getHttpDateFormat();
        headers.putSingle(HttpHeaders.DATE, format.format(new Date()));
    }
Example 6
public void filter(ContainerRequestContext requestContext) throws IOException {
        final String dateHeader = requestContext.getHeaderString(HttpHeaders.DATE);
        if (dateHeader == null) {
            throw new WebApplicationException(new IllegalArgumentException("Date Header was not specified"),
                    Response.Status.BAD_REQUEST);
        }
    }
Example 7
public Date getDate() {
        List<String> values = headers.get(HttpHeaders.DATE);
        if (values == null || StringUtils.isEmpty(values.get(0))) {
            return null;
        }
        return HttpUtils.getHttpDate(values.get(0));
    }
Example 8
public void testInboundHeaderThrowsException() throws ExecutionException, InterruptedException {
        final Response response = target("resource/inbound").request()
                .header(HttpHeaders.DATE, "foo")
                .post(Entity.entity("inbound", MediaType.TEXT_PLAIN_TYPE));
        Assert.assertEquals(400, response.getStatus());
    }
Example 9
private void addOzoneHeaders(HttpRequestBase httpRequest) {
    SimpleDateFormat format =
        new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ZZZ", Locale.US);

    httpRequest.addHeader(Header.OZONE_VERSION_HEADER,
        Header.OZONE_V1_VERSION_HEADER);
    httpRequest.addHeader(HttpHeaders.DATE,
        format.format(new Date(Time.monotonicNow())));
    if (getUserAuth() != null) {
      httpRequest.addHeader(HttpHeaders.AUTHORIZATION,
          Header.OZONE_SIMPLE_AUTHENTICATION_SCHEME + " " +
              getUserAuth());
    }
  }
Example 10
public void dateHeader_noDate_returnNegativeOne() {
        HttpServletRequest request = getRequest(REQUEST_FORM_URLENCODED_AND_QUERY, null, null);
        assertNotNull(request);
        assertEquals(-1L, request.getDateHeader(HttpHeaders.DATE));
    }