Package org.springframework.http

Examples of org.springframework.http.HttpHeaders


  // POST

  public URI postForLocation(String url, Object request, Object... urlVariables) throws RestClientException {
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request);
    HttpHeaders headers = execute(url, HttpMethod.POST, requestCallback, this.headersExtractor, urlVariables);
    return headers.getLocation();
  }
View Full Code Here


  }

  public URI postForLocation(String url, Object request, Map<String, ?> urlVariables)
      throws RestClientException {
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request);
    HttpHeaders headers = execute(url, HttpMethod.POST, requestCallback, this.headersExtractor, urlVariables);
    return headers.getLocation();
  }
View Full Code Here

    return headers.getLocation();
  }

  public URI postForLocation(URI url, Object request) throws RestClientException {
    HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request);
    HttpHeaders headers = execute(url, HttpMethod.POST, requestCallback, this.headersExtractor);
    return headers.getLocation();
  }
View Full Code Here

  }

  // OPTIONS

  public Set<HttpMethod> optionsForAllow(String url, Object... urlVariables) throws RestClientException {
    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, this.headersExtractor, urlVariables);
    return headers.getAllow();
  }
View Full Code Here

    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, this.headersExtractor, urlVariables);
    return headers.getAllow();
  }

  public Set<HttpMethod> optionsForAllow(String url, Map<String, ?> urlVariables) throws RestClientException {
    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, this.headersExtractor, urlVariables);
    return headers.getAllow();
  }
View Full Code Here

    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, this.headersExtractor, urlVariables);
    return headers.getAllow();
  }

  public Set<HttpMethod> optionsForAllow(URI url) throws RestClientException {
    HttpHeaders headers = execute(url, HttpMethod.OPTIONS, null, this.headersExtractor);
    return headers.getAllow();
  }
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public void doWithRequest(ClientHttpRequest httpRequest) throws IOException {
      super.doWithRequest(httpRequest);
      if (!requestEntity.hasBody()) {
        HttpHeaders httpHeaders = httpRequest.getHeaders();
        HttpHeaders requestHeaders = requestEntity.getHeaders();
        if (!requestHeaders.isEmpty()) {
          httpHeaders.putAll(requestHeaders);
        }
        if (httpHeaders.getContentLength() == -1) {
          httpHeaders.setContentLength(0L);
        }
      }
      else {
        Object requestBody = requestEntity.getBody();
        Class<?> requestType = requestBody.getClass();
        HttpHeaders requestHeaders = requestEntity.getHeaders();
        MediaType requestContentType = requestHeaders.getContentType();
        for (HttpMessageConverter messageConverter : getMessageConverters()) {
          if (messageConverter.canWrite(requestType, requestContentType)) {
            if (!requestHeaders.isEmpty()) {
              httpRequest.getHeaders().putAll(requestHeaders);
            }
            if (logger.isDebugEnabled()) {
              if (requestContentType != null) {
                logger.debug("Writing [" + requestBody + "] as \"" + requestContentType +
View Full Code Here

    Class<?> paramType = parameter.getParameterType();

    if (MultiValueMap.class.isAssignableFrom(paramType)) {
      MultiValueMap<String, String> result;
      if (HttpHeaders.class.isAssignableFrom(paramType)) {
        result = new HttpHeaders();
      }
      else {
        result = new LinkedMultiValueMap<String, String>();
      }
      for (Iterator<String> iterator = webRequest.getHeaderNames(); iterator.hasNext();) {
View Full Code Here

   * on the output message. It then calls {@link #writeInternal}.
   */
  public final void write(T t, MediaType contentType, HttpOutputMessage outputMessage)
      throws IOException, HttpMessageNotWritableException {

    HttpHeaders headers = outputMessage.getHeaders();
    if (headers.getContentType() == null) {
      if (contentType == null || contentType.isWildcardType() || contentType.isWildcardSubtype()) {
        contentType = getDefaultContentType(t);
      }
      if (contentType != null) {
        headers.setContentType(contentType);
      }
    }
    if (headers.getContentLength() == -1) {
      Long contentLength = getContentLength(t, headers.getContentType());
      if (contentLength != null) {
        headers.setContentLength(contentLength);
      }
    }
    writeInternal(t, outputMessage);
    outputMessage.getBody().flush();
  }
View Full Code Here

    HttpEntity<?> responseEntity = (HttpEntity<?>) returnValue;
    if (responseEntity instanceof ResponseEntity) {
      outputMessage.setStatusCode(((ResponseEntity<?>) responseEntity).getStatusCode());
    }

    HttpHeaders entityHeaders = responseEntity.getHeaders();
    if (!entityHeaders.isEmpty()) {
      outputMessage.getHeaders().putAll(entityHeaders);
    }
   
    Object body = responseEntity.getBody();
    if (body != null) {
View Full Code Here

TOP

Related Classes of org.springframework.http.HttpHeaders

Copyright © 2018 www.massapicom. 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.