List of usage examples for org.springframework.http HttpHeaders add
@Override public void add(String headerName, @Nullable String headerValue)
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 . jav a 2 s. c o m }
From source file:devbury.dewey.hipchat.api.Api.java
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpHeaders headers = request.getHeaders(); headers.add("Authorization", authorization); return execution.execute(request, body); }
From source file:spring.travel.site.controllers.LoginController.java
private ResponseEntity<User> success(User user) throws AuthException { HttpHeaders headers = new HttpHeaders(); headers.add("Set-Cookie", cookie(user) + "; path=/"); return new ResponseEntity<>(user, headers, HttpStatus.OK); }
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 . j av a 2 s. c o m*/ }
From source file:org.cloudfoundry.identity.uaa.integration.VarzEndpointIntegrationTests.java
/** * tests a happy-day flow of the <code>/varz</code> endpoint *///from w ww. j a v a 2 s .c o m @Test public void testHappyDay() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", testAccounts.getVarzAuthorizationHeader()); ResponseEntity<String> response = serverRunning.getForString("/varz", headers); assertEquals(HttpStatus.OK, response.getStatusCode()); String map = response.getBody(); assertTrue(map.contains("spring.application")); assertTrue(map.contains("Catalina")); }
From source file:org.cloudfoundry.identity.uaa.integration.VarzEndpointIntegrationTests.java
/** * tests a unauthorized flow of the <code>/varz</code> endpoint *//*from w ww.j a v a2 s .c o m*/ @Test public void testUnauthorized() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", String.format("Basic %s", new String(Base64.encode("varz:bogus".getBytes())))); ResponseEntity<String> response = serverRunning.getForString("/varz", headers); assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); String map = response.getBody(); // System.err.println(map); assertTrue(map.contains("{\"error\"")); }
From source file:sp.SAML1Controller.java
@RequestMapping(value = "/POST/ACS", method = RequestMethod.POST) public ResponseEntity<String> handleSSOResponsePOST(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception { MessageContext<SAMLObject> messageContext = decodeInboundMessageContextPost(servletRequest); if (!(messageContext.getMessage() instanceof Response)) { log.error("Inbound message was not a SAML 1 Response"); return new ResponseEntity<>("Inbound message was not a SAML 1 Response", HttpStatus.BAD_REQUEST); }/*from ww w . ja va 2s .com*/ Response response = (Response) messageContext.getMessage(); Element responseElement = response.getDOM(); String formattedMessage = SerializeSupport.prettyPrintXML(responseElement); log.trace("Returning response" + System.lineSeparator() + "{}", formattedMessage); //TODO instead of returning plain text via a ResponseEntity, add a JSP view that looks good HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "text/plain"); return new ResponseEntity<>(formattedMessage, headers, HttpStatus.OK); }
From source file:com.biz.report.controller.CustomerReportControler.java
@ResponseBody @RequestMapping(value = "customerreport/{year}/get", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<ReportDataSet> readFTypes(@PathVariable("year") String year, @RequestBody Map data) { logger.info(year);/*from w w w . j av a 2s.co m*/ logger.info(data); Assert.notNull(data, "Data is null."); Assert.notNull(year, "Year is null."); String items = data.get("customers").toString(); String months = data.get("months").toString(); ReportDataSet reportDataSet = customerService.getReports(items, months, year); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<ReportDataSet>(reportDataSet, headers, HttpStatus.OK); }
From source file:com.biz.report.controller.ItemDashBoardController.java
@ResponseBody @RequestMapping(value = "sales/{year}/read", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<List<SalesDTO>> readItemByType(@RequestBody Map map, @PathVariable("year") String year) { Assert.notNull(year, "Year is null."); Assert.notNull(map, "Type is null."); String itemName = map.get("item").toString(); String month = map.get("month") != null ? map.get("month").toString() : null; HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<List<SalesDTO>>(itemDashBoardService.readByItemName(itemName, year, month), headers, HttpStatus.OK);/*ww w . j a v a 2 s. c o m*/ }
From source file:com.biz.report.controller.RepReportController.java
@ResponseBody @RequestMapping(value = "repreport/{year}/get", method = RequestMethod.POST, headers = { "Content-type=application/json" }) public ResponseEntity<ReportDataSet> readFTypes(@PathVariable("year") String year, @RequestBody Map data) { logger.info(year);//from w w w. j a va2 s . c om logger.info(data); Assert.notNull(data, "Data is null."); Assert.notNull(year, "Year is null."); String reps = data.get("reps").toString(); String months = data.get("months").toString(); ReportDataSet reportDataSet = repReportService.getReports(reps, months, year); HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<ReportDataSet>(reportDataSet, headers, HttpStatus.OK); }