Package org.springframework.http

Examples of org.springframework.http.HttpHeaders.containsKey()


  @Override
  protected ResponseEntity<OAuth2Exception> enhanceResponse(ResponseEntity<OAuth2Exception> response, Exception exception) {
    HttpHeaders headers = response.getHeaders();
    String existing = null;
    if (headers.containsKey("WWW-Authenticate")) {
      existing = extractTypePrefix(headers.getFirst("WWW-Authenticate"));
    }
    StringBuilder builder = new StringBuilder();
    builder.append(typeName+" ");
    builder.append("realm=\"" + realmName + "\"");
View Full Code Here


    mockRequest.setContentType("text/plain");
    mockRequest.setCharacterEncoding("UTF-8");

    HttpHeaders headers = request.getHeaders();
    assertNotNull("No HttpHeaders returned", headers);
    assertTrue("Invalid headers returned", headers.containsKey(headerName));
    List<String> headerValues = headers.get(headerName);
    assertEquals("Invalid header values returned", 2, headerValues.size());
    assertTrue("Invalid header values returned", headerValues.contains(headerValue1));
    assertTrue("Invalid header values returned", headerValues.contains(headerValue2));
    assertEquals("Invalid Content-Type", new MediaType("text", "plain", Charset.forName("UTF-8")),
View Full Code Here

    mockRequest.setContentType("");
    mockRequest.setCharacterEncoding("");

    HttpHeaders headers = request.getHeaders();
    assertNotNull("No HttpHeaders returned", headers);
    assertTrue("Invalid headers returned", headers.containsKey(headerName));
    List<String> headerValues = headers.get(headerName);
    assertEquals("Invalid header values returned", 2, headerValues.size());
    assertTrue("Invalid header values returned", headerValues.contains(headerValue1));
    assertTrue("Invalid header values returned", headerValues.contains(headerValue2));
    assertNull(headers.getContentType());
View Full Code Here

  @Test
  public void headForHeaders() throws Exception {
    Future<HttpHeaders> headersFuture = template.headForHeaders(baseUrl + "/get");
    HttpHeaders headers = headersFuture.get();
    assertTrue("No Content-Type header", headers.containsKey("Content-Type"));
  }

  @Test
  public void headForHeadersCallback() throws Exception {
    ListenableFuture<HttpHeaders> headersFuture = template.headForHeaders(baseUrl + "/get");
View Full Code Here

    interceptors.add(new ClientHttpRequestInterceptor() {
      public ClientHttpResponse intercept(HttpRequest request, byte[] body,
          ClientHttpRequestExecution execution) throws IOException {
        if (matchHost(request.getURI().getHost())) {
          HttpHeaders headers = request.getHeaders();
          if (!headers.containsKey("Authorization")) {
            String authString = computeAuthString();
            headers.add("Authorization", authString);
          }
        }
        return execution.execute(request, body);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.