List of usage examples for org.springframework.http HttpHeaders HttpHeaders
public HttpHeaders()
From source file:edu.infsci2560.LoginIT.java
@Test public void testLoginPageValid() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = this.restTemplate.exchange("/login", HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); PageHtmlValidator.validatePage(entity.getBody()); }
From source file:edu.wisc.cypress.dao.ernstmt.RestEarningStatementDao.java
@Cacheable(cacheName = "earningStatement", exceptionCacheName = "cypressUnknownExceptionCache") @Override//from w ww.j av a 2s . co m public EarningStatements getEarningStatements(String emplid) { final HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.set("HRID", emplid); final XmlEarningStatements xmlEarningStatements = this.restOperations.getForObject(this.statementsUrl, XmlEarningStatements.class, httpHeaders, emplid); return this.mapEarningStatements(xmlEarningStatements); }
From source file:io.fabric8.che.starter.client.keycloak.KeycloakClient.java
private String getResponseBody(KeycloakEndpoint endpoint, String authHeader) { RestTemplate template = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); headers.add("Authorization", authHeader); HttpEntity<String> entity = new HttpEntity<String>("parameters", headers); ResponseEntity<String> response = template.exchange(endpoint.toString(), HttpMethod.GET, entity, String.class); return response.getBody(); }
From source file:tools.RequestSendingRunnable.java
private RequestEntity<Void> requestWithTraceId() { HttpHeaders headers = new HttpHeaders(); headers.add(Span.TRACE_ID_NAME, Span.idToHex(this.traceId)); headers.add(Span.SPAN_ID_NAME, Span.idToHex(this.spanId)); URI uri = URI.create(this.url); RequestEntity<Void> requestEntity = new RequestEntity<>(headers, HttpMethod.GET, uri); log.info("Request [" + requestEntity + "] is ready"); return requestEntity; }
From source file:com.company.eleave.leave.rest.HolidayController.java
@RequestMapping(method = RequestMethod.POST) public ResponseEntity<Long> createNew(@RequestBody HolidayDTO holiday) { final long holidayId = holidayService.createNew(mapper.toEntity(holiday)); HttpHeaders headers = new HttpHeaders(); headers.setLocation(UriComponentsBuilder.fromPath("/leaveTypes/{id}").buildAndExpand(holidayId).toUri()); return new ResponseEntity<>(headers, HttpStatus.CREATED); }
From source file:de.codecentric.boot.admin.services.ApplicationRegistratorTest.java
@Before public void setup() { restTemplate = mock(RestTemplate.class); adminProps = new AdminProperties(); adminProps.setUrl(new String[] { "http://sba:8080", "http://sba2:8080" }); AdminClientProperties clientProps = new AdminClientProperties(); clientProps.setManagementUrl("http://localhost:8080/mgmt"); clientProps.setHealthUrl("http://localhost:8080/health"); clientProps.setServiceUrl("http://localhost:8080"); clientProps.setName("AppName"); registrator = new ApplicationRegistrator(restTemplate, adminProps, clientProps); headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); }
From source file:io.sevenluck.chat.controller.UserController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ResponseEntity<?> handleException(Exception ex) { logger.error("error:", ex); return new ResponseEntity<>(new User(0L, "b", "a"), new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR); }
From source file:es.upm.oeg.tools.quality.ldsniffer.webapp.EvalController.java
@RequestMapping("/eval") public ResponseEntity<String> eval(@RequestParam("uriList") String uriList, @RequestParam("metricList") String metricList, @RequestParam("metricDef") String metricDef, @RequestParam("timeout") String timeout) throws IOException { Preconditions.checkNotNull(uriList, "uriList parameter is required and can not be null"); logger.info("uriList value : \n'{}'", uriList); // Evaluating the URI list String result = LDSnifferApp.eval(parseUriList(uriList), true, 10); // Creating the HTTP response HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.setContentType(new MediaType("text", "turtle")); return new ResponseEntity<String>(result, responseHeaders, HttpStatus.OK); }
From source file:io.sevenluck.chat.controller.ChatRoomController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ResponseEntity<?> handleException(ChatRoomAlreadyExists e) { logger.error("validate:", e.getMessage()); return new ResponseEntity<>(ExceptionDTO.newConflictInstance(e.getMessage()), new HttpHeaders(), HttpStatus.CONFLICT);/*from w w w . j a v a 2 s . co m*/ }
From source file:com.github.hateoas.forms.spring.sample.test.ReviewController.java
@RequestMapping(value = "/events/{eventId}", method = RequestMethod.POST) public @ResponseBody ResponseEntity<Void> addReview(@PathVariable int eventId, @RequestBody Review review) { Assert.notNull(review);/* w w w . ja va 2s . c om*/ Assert.notNull(review.getReviewRating()); Assert.notNull(review.getReviewRating().getRatingValue()); final HttpHeaders headers = new HttpHeaders(); headers.setLocation(AffordanceBuilder .linkTo(AffordanceBuilder.methodOn(this.getClass()).getReviews(eventId, null)).toUri()); return new ResponseEntity(headers, HttpStatus.CREATED); }