List of usage examples for org.springframework.http HttpHeaders setETag
public void setETag(@Nullable String etag)
From source file:org.lightadmin.core.web.util.ResponseUtils.java
public static HttpHeaders octetStreamResponseHeader(MediaType mediaType, long length, String eTag) { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentLength(length); responseHeaders.setContentType(mediaType); responseHeaders.setCacheControl("max-age"); if (isNotBlank(eTag)) { responseHeaders.setETag(eTag); }/*from www . j a v a2s . c o m*/ responseHeaders.set("Content-Disposition", "inline; filename=\"file.jpg\""); return responseHeaders; }
From source file:net.eusashead.hateoas.conditional.interceptor.SyncTestController.java
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<String> get() { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<String>("hello", headers, HttpStatus.OK); }
From source file:net.eusashead.hateoas.conditional.interceptor.SyncTestController.java
@RequestMapping(method = RequestMethod.HEAD) public ResponseEntity<String> head() { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<String>(headers, HttpStatus.OK); }
From source file:net.eusashead.hateoas.conditional.interceptor.SyncTestController.java
@RequestMapping(method = RequestMethod.PUT) public ResponseEntity<Void> put() { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<Void>(headers, HttpStatus.NO_CONTENT); }
From source file:net.eusashead.hateoas.conditional.interceptor.AsyncTestController.java
@RequestMapping(method = RequestMethod.PUT) public Callable<ResponseEntity<Void>> put() { return new Callable<ResponseEntity<Void>>() { @Override// w w w . j av a 2 s . c o m public ResponseEntity<Void> call() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<Void>(headers, HttpStatus.NO_CONTENT); } }; }
From source file:net.eusashead.hateoas.conditional.interceptor.AsyncTestController.java
@RequestMapping(method = RequestMethod.GET) public Callable<ResponseEntity<String>> get() { return new Callable<ResponseEntity<String>>() { @Override//from ww w . j a v a 2s .c o m public ResponseEntity<String> call() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<String>("hello", headers, HttpStatus.OK); } }; }
From source file:net.eusashead.hateoas.conditional.interceptor.AsyncTestController.java
@RequestMapping(method = RequestMethod.HEAD) public Callable<ResponseEntity<Void>> head() { return new Callable<ResponseEntity<Void>>() { @Override/* w w w . j ava 2 s. co m*/ public ResponseEntity<Void> call() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setETag("\"123456\""); return new ResponseEntity<Void>(headers, HttpStatus.OK); } }; }
From source file:org.zalando.riptide.CaptureTest.java
@Test public void shouldCaptureMappedEntity() { final String revision = '"' + "1aa9520a-0cdd-11e5-aa27-8361dd72e660" + '"'; final HttpHeaders headers = new HttpHeaders(); headers.setETag(revision); server.expect(requestTo(url)).andRespond(withSuccess().body(new ClassPathResource("account.json")) .contentType(APPLICATION_JSON).headers(headers)); final Account account = unit.execute(GET, url) .dispatch(status(), on(OK, AccountBody.class).capture(this::extract), anyStatus().call(this::fail)) .to(Account.class); assertThat(account.getId(), is("1234567890")); assertThat(account.getRevision(), is(revision)); assertThat(account.getName(), is("Acme Corporation")); }
From source file:org.zalando.riptide.CaptureTest.java
@Test public void shouldMapAndCaptureEntity() { final String revision = '"' + "1aa9520a-0cdd-11e5-aa27-8361dd72e660" + '"'; final HttpHeaders headers = new HttpHeaders(); headers.setETag(revision); server.expect(requestTo(url)).andRespond(withSuccess().body(new ClassPathResource("account.json")) .contentType(APPLICATION_JSON).headers(headers)); final Account account = unit.execute(GET, url) .dispatch(status(), on(OK, AccountBody.class).capture(this::extract), anyStatus().call(this::fail)) .to(Account.class); assertThat(account.getId(), is("1234567890")); assertThat(account.getRevision(), is(revision)); assertThat(account.getName(), is("Acme Corporation")); }
From source file:net.eusashead.hateoas.response.argumentresolver.AsyncEntityControllerITCase.java
@Test public void testHead() throws Exception { // Expected result HttpHeaders headers = new HttpHeaders(); headers.setETag("W/\"b0c689597eb9dd62c0a1fb90a7c5c5a5\""); ResponseEntity<Entity> expectedResult = new ResponseEntity<Entity>(headers, HttpStatus.NO_CONTENT); // Execute asynchronously MvcResult mvcResult = this.mockMvc .perform(request(HttpMethod.HEAD, "http://localhost/async/foo") .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andExpect(request().asyncStarted()).andExpect(request().asyncResult(expectedResult)).andReturn(); // Perform asynchronous dispatch this.mockMvc.perform(asyncDispatch(mvcResult)).andDo(print()).andExpect(status().isNoContent()) .andExpect(header().string("ETag", "W/\"b0c689597eb9dd62c0a1fb90a7c5c5a5\"")); }