Package org.springframework.http

Examples of org.springframework.http.HttpHeaders


    }
  }

  public static HttpHeaders httpHeaderAttachment(final String filename,
      final MimeType mime, final int fileSize) {
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.set("charset", "utf-8");
    responseHeaders
        .setContentType(MediaType.parseMediaType(mime.getType()));
    responseHeaders.setContentLength(fileSize);
    responseHeaders.set("Content-disposition", "attachment; filename=\""
        + filename + "." + mime.name().toLowerCase() + "\"");
    return responseHeaders;

  }
View Full Code Here


    public DropboxFile getThumbnail(String path) {
      try {
        UriTemplate uriTemplate = new UriTemplate(THUMBNAILS_URL);
      URI uri = uriTemplate.expand(appFolderUrl, path);
        ClientHttpResponse response = getRestTemplate().getRequestFactory().createRequest(uri, HttpMethod.GET).execute();
        HttpHeaders headers = response.getHeaders();
       
        return new DropboxFile(
            headers.getContentType().toString(),
            headers.getContentLength(),
            response.getBody());
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
View Full Code Here

    public DropboxFile getFile(String path) {
      try {
      UriTemplate uriTemplate = new UriTemplate(FILE_URL);
    URI uri = uriTemplate.expand(appFolderUrl, path);
      ClientHttpResponse response = getRestTemplate().getRequestFactory().createRequest(uri, HttpMethod.GET).execute();
      HttpHeaders headers = response.getHeaders();
     
      return new DropboxFile(
          headers.getContentType().toString(),
          headers.getContentLength(),
          response.getBody());
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
View Full Code Here

        // dynamically register this client
        JsonObject jsonRequest = ClientDetailsEntityJsonProcessor.serialize(template);
        String serializedClient = gson.toJson(jsonRequest);

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        headers.setAccept(Lists.newArrayList(MediaType.APPLICATION_JSON));

        HttpEntity<String> entity = new HttpEntity<String>(serializedClient, headers);

        String registered = restTemplate.postForObject(serverConfig.getRegistrationEndpointUri(), entity, String.class);
        // TODO: handle HTTP errors

        RegisteredClient client = ClientDetailsEntityJsonProcessor.parseRegistered(registered);

        // save this client for later
        registeredClientService.save(serverConfig.getIssuer(), client);

        return client;
      } else {

        if (knownClient.getClientId() == null) {
       
          // load this client's information from the server
          HttpHeaders headers = new HttpHeaders();
          headers.set("Authorization", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, knownClient.getRegistrationAccessToken()));
          headers.setAccept(Lists.newArrayList(MediaType.APPLICATION_JSON));
 
          HttpEntity<String> entity = new HttpEntity<String>(headers);
 
          String registered = restTemplate.exchange(knownClient.getRegistrationClientUri(), HttpMethod.GET, entity, String.class).getBody();
          // TODO: handle HTTP errors
View Full Code Here

                    accessToken.getSecret(),
                    userId);
    authorizationService.createAuthorization(authorization);
    requestTokens.remove(oauth_token);
    oAuthServices.remove(requestToken);
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.TEXT_HTML) ;
    return new ResponseEntity<String>(
        "<script type=\"text/javascript\">window.close();</script>",
        responseHeaders, HttpStatus.OK);
  }
View Full Code Here

    return this.httpMethod.getStatusText();
  }

  public HttpHeaders getHeaders() {
    if (this.headers == null) {
      this.headers = new HttpHeaders();
      for (Header header : this.httpMethod.getResponseHeaders()) {
        this.headers.add(header.getName(), header.getValue());
      }
    }
    return this.headers;
View Full Code Here

  // 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

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.