Example usage for org.springframework.http HttpHeaders HttpHeaders

List of usage examples for org.springframework.http HttpHeaders HttpHeaders

Introduction

In this page you can find the example usage for org.springframework.http HttpHeaders HttpHeaders.

Prototype

public HttpHeaders() 

Source Link

Document

Construct a new, empty instance of the HttpHeaders object.

Usage

From source file:com.companyname.plat.commons.client.HttpRestfulClient.java

private HttpHeaders getUnsecuredHeaders() {
    HttpHeaders headers = new HttpHeaders();

    if (getContentTypeHeader() != null) {
        headers.setContentType(getContentTypeHeader());
    }//w w w .j a v a  2 s .  c om

    if (getAcceptHeader() != null) {
        headers.setAccept(Arrays.asList(getAcceptHeader()));
    }

    return headers;
}

From source file:edu.wisc.cypress.dao.sabstmt.RestSabbaticalStatementDao.java

@Override
public void getSabbaticalReport(String emplid, String docId, ProxyResponse proxyResponse) {
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.set("HRID", emplid);
    this.restOperations.proxyRequest(proxyResponse, this.statementUrl, HttpMethod.GET, httpHeaders, docId);
}

From source file:eu.agilejava.javaonedemo.api.RecipeResource.java

@RequestMapping(method = RequestMethod.POST, consumes = APPLICATION_JSON_VALUE)
public ResponseEntity<Recipe> create(@RequestBody Recipe recipe) {
    recipeService.create(recipe);/*ww w .  j a  v  a2s.c  o m*/

    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.add("Location", ServletUriComponentsBuilder.fromCurrentRequestUri()
            .pathSegment(String.valueOf(recipe.getId())).build().toUriString());
    return new ResponseEntity<>(responseHeaders, HttpStatus.CREATED);
}

From source file:de.escalon.hypermedia.spring.sample.ReviewController.java

@Action("ReviewAction")
@RequestMapping(value = "/events/{eventId}", method = RequestMethod.POST, params = { "review", "rating" })
public @ResponseBody ResponseEntity<Void> addReview(@PathVariable int eventId, @RequestParam String review,
        @RequestParam int rating) {
    final HttpHeaders headers = new HttpHeaders();
    headers.setLocation(//from  w  w w.j  a  va  2 s .c  om
            AffordanceBuilder.linkTo(AffordanceBuilder.methodOn(this.getClass()).getReviews(eventId)).toUri());
    return new ResponseEntity(headers, HttpStatus.CREATED);
}

From source file:org.wallride.web.support.ControllerUtils.java

public static ResponseEntity<?> createRedirectResponseEntity(HttpServletRequest nativeRequest,
        HttpServletResponse nativeResponse, String path) {
    UrlPathHelper pathHelper = new UrlPathHelper();
    String url = pathHelper.getContextPath(nativeRequest) + path;
    String encodedUrl = nativeResponse.encodeRedirectURL(url);

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(URI.create(encodedUrl));

    ResponseEntity<?> response = new ResponseEntity<>(null, headers, HttpStatus.FOUND);
    return response;
}

From source file:com.biz.report.controller.RepReportController.java

@ResponseBody
@RequestMapping(value = "reps/items/{year}/read", method = RequestMethod.POST, headers = {
        "Content-type=application/json" })
public ResponseEntity<List<ItemDTO>> readItemByType(@RequestBody Map map, @PathVariable("year") String year) {
    Assert.notNull(year, "Year is null.");
    Assert.notNull(map, "Type is null.");
    String reps = map.get("reps").toString();
    String month = map.get("month") != null ? map.get("month").toString() : null;
    HttpHeaders headers = new HttpHeaders();
    headers.add("success", "Success");
    return new ResponseEntity<List<ItemDTO>>(repReportService.readByRepName(reps, year, month), headers,
            HttpStatus.OK);//from w  w  w.  jav a2 s.  co m
}

From source file:com.biz.report.controller.CustomerReportControler.java

@ResponseBody
@RequestMapping(value = "customers/items/{year}/read", method = RequestMethod.POST, headers = {
        "Content-type=application/json" })
public ResponseEntity<List<ItemDTO>> readItemByType(@RequestBody Map map, @PathVariable("year") String year) {
    Assert.notNull(year, "Year is null.");
    Assert.notNull(map, "Type is null.");
    String customers = map.get("customers").toString();
    String month = map.get("month") != null ? map.get("month").toString() : null;
    HttpHeaders headers = new HttpHeaders();
    headers.add("success", "Success");
    return new ResponseEntity<List<ItemDTO>>(customerService.readByCustomerName(customers, year, month),
            headers, HttpStatus.OK);//from w ww. j av  a2s . co m
}

From source file:com.alcatel.hello.actuator.ui.SampleActuatorUIApplicationTests.java

@Test
public void testError() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/error",
            HttpMethod.GET, new HttpEntity<Void>(headers), String.class);

    assertEquals(HttpStatus.OK, entity.getStatusCode());
    assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("<html>"));
    assertTrue("Wrong body:\n" + entity.getBody(), entity.getBody().contains("<body>"));
    assertTrue("Wrong body:\n" + entity.getBody(),
            entity.getBody().contains("Please contact the operator with the above information"));
}

From source file:org.cloudfoundry.identity.uaa.scim.RemoteScimUserProvisioningTests.java

@Test
public void testRemoveUser() {
    HttpHeaders headers = new HttpHeaders();
    headers.set("If-Match", "123456789");
    Mockito.when(restTemplate.exchange(Mockito.eq("http://base/User/{id}"), Mockito.eq(HttpMethod.DELETE),
            Mockito.argThat(new HttpHeadersMatcher()), Mockito.eq(ScimUser.class), Mockito.eq("1234")))
            .thenReturn(new ResponseEntity<ScimUser>(user, HttpStatus.OK));
    service.removeUser("1234", 123456789);
}

From source file:eu.falcon.semantic.client.DenaClient.java

public static String getClassSubclasses(String classURI) {

    final String uri = "http://falconsemanticmanager.euprojects.net/api/v1/ontology/class/subclasses";
    //final String uri = "http://localhost:8090/api/v1/ontology/class/subclasses";

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);

    RestTemplate restTemplate = new RestTemplate();

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

    String result = restTemplate.postForObject(uri, entity, String.class);

    return result;
}