Package org.springframework.http

Examples of org.springframework.http.HttpHeaders


  }
 
  @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  public @ResponseBody ResponseEntity<Object> deleteMovie(@PathVariable UUID id) {
    movieService.deleteMovie(id);
    HttpHeaders headers = new HttpHeaders();
    headers.set("Access-Control-Allow-Origin", "*");
    return new ResponseEntity<Object>(null, headers, HttpStatus.NO_CONTENT);
  }
View Full Code Here


    movie.getComments().add(new Comment(new Date(), content));
    return enableCorsRequests(movieResourceAssembler.toResource(movie), HttpStatus.CREATED);
  }
 
  private <T> ResponseEntity<T> enableCorsRequests(T entity, HttpStatus statusCode) {
    HttpHeaders headers = new HttpHeaders();
    headers.set("Access-Control-Allow-Origin", "*");
    return new ResponseEntity<T>(entity, headers, statusCode);
  }
View Full Code Here

    Map<String, Object> extraProperties = request.getExtraProperties();

    delegate.createCluster(request.getClusterId(), request.getClusterDef(), projectionData, extraProperties);

    HttpHeaders responseHeaders = new HttpHeaders();
    UriComponents uriComponents = MvcUriComponentsBuilder
          .fromMethodCall(on(YarnContainerClusterMvcEndpoint.class).clusterInfo(request.getClusterId())).build();
    responseHeaders.setLocation(uriComponents.toUri());

    return new ResponseEntity<Void>(responseHeaders, HttpStatus.CREATED);
  }
View Full Code Here

  }

  @Override
  public DriveFile upload(Resource resource, DriveFile metadata, UploadParameters parameters) {
   
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MULTIPART_FORM_DATA);
   
    MultiValueMap<String, Object> body = new LinkedMultiValueMap<String, Object>();
    body.add("metadata", metadata);
    body.add("file", resource);
   
View Full Code Here

  }

  @Override
  @SuppressWarnings({ "unchecked", "rawtypes" })
  protected AccessGrant postForAccessGrant(String accessTokenUrl, MultiValueMap<String, String> parameters) {
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<MultiValueMap<String, String>>(parameters, headers);
    ResponseEntity<Map> responseEntity = getRestTemplate().exchange(accessTokenUrl, HttpMethod.POST, requestEntity, Map.class);
    Map<String, Object> responseMap = responseEntity.getBody();
    return extractAccessGrant(responseMap);
  }
View Full Code Here

    Resource s2logo = new ClassPathResource(resourcePath);
    MultiValueMap<String, Object> multipartMap = new LinkedMultiValueMap<String, Object>();
    multipartMap.add("company", "SpringSource");
    multipartMap.add("company-logo", s2logo);
    logger.info("Created multipart request: " + multipartMap);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(new MediaType("multipart", "form-data"));
    HttpEntity<Object> request = new HttpEntity<Object>(multipartMap, headers);
    logger.info("Posting request to: " + uri);
    ResponseEntity<?> httpResponse = template.exchange(uri, HttpMethod.POST, request, Object.class);
    if (!httpResponse.getStatusCode().equals(HttpStatus.OK)){
      logger.error("Problems with the request. Http status: " + httpResponse.getStatusCode());
View Full Code Here

    EmployeeList employeeList = restTemplate.execute(fullUrl, HttpMethod.GET,
        new RequestCallback() {
          @Override
          public void doWithRequest(ClientHttpRequest request) throws IOException {
            HttpHeaders headers = getHttpHeadersWithUserCredentials(request);
            headers.add("Accept", "application/xml");
          }
    }, responseExtractor, employeeSearchMap);

    logger.info("The employee list size :"+employeeList.getEmployee().size());
View Full Code Here

  @Test
  public void testGetEmployeeAsJson() throws Exception{
    Map<String, Object> employeeSearchMap = getEmployeeSearchMap("0");

    final String fullUrl = "http://localhost:8080/rest-http/services/employee/{id}/search?format=json";
    HttpHeaders headers = getHttpHeadersWithUserCredentials(new HttpHeaders());
    headers.add("Accept", "application/json");
    HttpEntity<Object> request = new HttpEntity<Object>(headers);

    ResponseEntity<?> httpResponse = restTemplate.exchange(fullUrl, HttpMethod.GET, request, EmployeeList.class, employeeSearchMap);
    logger.info("Return Status :"+httpResponse.getHeaders().get("X-Return-Status"));
    logger.info("Return Status Message :"+httpResponse.getHeaders().get("X-Return-Status-Msg"));
View Full Code Here

    @Override
    public Response execute(Request request, Request.Options options) throws IOException {
        RestTemplate restTemplate = new RestTemplate();
        HttpMethod method = HttpMethod.valueOf(request.method());

        HttpHeaders requestHeaders = new HttpHeaders();
        for (String header: request.headers().keySet()) {
            Collection<String> values = request.headers().get(header);
            if (values != null && !values.isEmpty())
                requestHeaders.put(header, new ArrayList<>(values));
        }

        HttpEntity<byte[]> httpEntity = new HttpEntity<>(request.body(), requestHeaders);

        ResponseEntity<byte[]> responseEntity = restTemplate.exchange(request.url(), method, httpEntity, byte[].class);
View Full Code Here

    }

  @RequestMapping(headers = "Accept=application/json")
    @ResponseBody
    public ResponseEntity<String> listJson(Authentication authentication) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json; charset=utf-8");
        User user=(User) authentication.getPrincipal();
        List<Todo> result = todoService.findTodosByUserName(user.getUsername());
        return new ResponseEntity<String>(Todo.toJsonArray(result), headers, HttpStatus.OK);
    }
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.