List of usage examples for org.springframework.http HttpHeaders HttpHeaders
public HttpHeaders()
From source file:com.appglu.impl.StorageTemplateTest.java
@Before public void setup() { super.setup(); storageOperations = appGluTemplate.storageOperations(); downloadMockServer = MockRestServiceServer.createServer(appGluTemplate.getDownloadRestTemplate()); responseHeaders = new HttpHeaders(); responseHeaders.setETag(ETAG);/*from w ww . ja v a 2 s . c om*/ }
From source file:org.esupportail.papercut.web.PayBoxCallbackController.java
/** * Manage callback response from paybox - url like : * /*from ww w. java 2 s . co m*/ * /payboxcallback?montant=200&reference=bonamvin@univrouen@200-2013-08-23-17-08-18-394&auto=XXXXXX&erreur=00000&idtrans=3608021&signature=CPqq18Un24NL0llB3E3G9kbKI4ztlkoL%2BSRTnMMrWlPBTVNTsn%2B%2FxA0YMSQOGGnU0wm45HYh%2F2RHoZGG3THzj7xKSY6upNJcnKrfFmzfTgA5FTFA3dyM27RgKmLcCeH48FRNoZPjVsKk0G2npvaP%2FY5pkSvn%2BQUl34DkmJkTejs%3D * * @param uiModel * @return empty page */ @RequestMapping("/payboxcallback") @ResponseBody public ResponseEntity<String> index(@RequestParam String montant, @RequestParam String reference, @RequestParam(required = false) String auto, @RequestParam String erreur, @RequestParam String idtrans, @RequestParam String signature, HttpServletRequest request) { String paperCutContext = reference.split("@")[1]; String ip = request.getRemoteAddr(); String queryString = request.getQueryString(); if (esupPaperCutServices.get(paperCutContext).payboxCallback(montant, reference, auto, erreur, idtrans, signature, queryString, ip, null)) { HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "text/html; charset=utf-8"); return new ResponseEntity<String>("", headers, HttpStatus.OK); } else { HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "text/html; charset=utf-8"); return new ResponseEntity<String>("", headers, HttpStatus.FORBIDDEN); } }
From source file:edu.mayo.cts2.uriresolver.controller.ResolveURI.java
@RequestMapping(method = RequestMethod.PUT, value = "/versions/{type}/{identifier}") public ResponseEntity<String> saveVersionIdentifiers(@RequestBody UriResults uriResults, @PathVariable String type, @PathVariable String identifier) { logger.info("\n\nsaveVersionIdentifiers\n\n"); uriDAO.saveVersionIdentifiers(uriResults); logger.info("finshed saving"); return new ResponseEntity<String>(new HttpHeaders(), HttpStatus.OK); }
From source file:com.tce.oauth2.spring.client.services.TodoService.java
public List<Todo> findByUsername(String accessToken, String username) { HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer " + accessToken); HttpEntity<String> entity = new HttpEntity<String>(headers); ResponseEntity<Todo[]> response = restTemplate.exchange( OAUTH_RESOURCE_SERVER_URL + "/rest/todos/" + username, HttpMethod.GET, entity, Todo[].class); Todo[] todos = response.getBody();/*from w ww . ja va 2 s. c o m*/ return Arrays.asList(todos); }
From source file:org.appverse.web.framework.backend.frontfacade.rest.MvcExceptionHandlerTests.java
@Test public void test() throws Exception { // Login first TestLoginInfo loginInfo = login();//from www .j av a 2 s. c om HttpHeaders headers = new HttpHeaders(); headers.set("Cookie", loginInfo.getJsessionid()); HttpEntity<String> entity = new HttpEntity<String>(headers); // Calling protected resource - requires CSRF token UriComponentsBuilder builder = UriComponentsBuilder .fromHttpUrl("http://localhost:" + port + baseApiPath + "/hello") .queryParam(DEFAULT_CSRF_PARAMETER_NAME, loginInfo.getXsrfToken()); ResponseEntity<String> responseEntity = restTemplate.exchange(builder.build().encode().toUri(), HttpMethod.GET, entity, String.class); String data = responseEntity.getBody(); assertEquals("Hello World!", data); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); }
From source file:com.interop.webapp.WebAppTests.java
@Test public void testLoginPage() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity<String> entity = new TestRestTemplate().exchange("http://localhost:" + this.port + "/login", HttpMethod.GET, new HttpEntity<Void>(headers), String.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); assertTrue("Wrong content:\n" + entity.getBody(), entity.getBody().contains("_csrf")); }
From source file:de.muenchen.eaidemo.AbstractIntegrationTest.java
/** * @param requestMappingUrl should be exactly the same as defined in your * RequestMapping value attribute (including the parameters in {}) * RequestMapping(value = yourRestUrl)//from www .ja va 2s. co m * @param serviceReturnTypeClass should be the the return type of the * service * @param parametersInOrderOfAppearance should be the parameters of the * requestMappingUrl ({}) in order of appearance * @return the result of the service, or null on error */ protected <T> T getEntity(final String requestMappingUrl, final Class<T> serviceReturnTypeClass, final Object... parametersInOrderOfAppearance) { // Make a rest template do do the service call final TestRestTemplate restTemplate = new TestRestTemplate(); // Add correct headers, none for this example final HttpEntity<String> requestEntity = new HttpEntity<String>(new HttpHeaders()); try { // Do a call to the url final ResponseEntity<T> entity = restTemplate.exchange(getBaseUrl() + requestMappingUrl, HttpMethod.GET, requestEntity, serviceReturnTypeClass, parametersInOrderOfAppearance); // Return result return entity.getBody(); } catch (final Exception ex) { // Handle exceptions } return null; }
From source file:org.schedoscope.metascope.controller.MetascopeDataDistributionControllerTest.java
@Test public void sometest() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.set("Referer", "/test"); HttpEntity<String> entity = new HttpEntity<String>("parameters", headers); ResponseEntity<String> response = this.restTemplate.exchange("/datadistribution/start?fqdn=test", HttpMethod.POST, entity, String.class); assertEquals(302, response.getStatusCodeValue()); assertTrue(response.getHeaders().get("Location").get(0).endsWith("/test#datadistributionContent")); }
From source file:guru.nidi.ramltester.RestTemplateTest.java
@RequestMapping(value = "/data") @ResponseBody//from w ww . j ava2 s. c om public HttpEntity<String> test(@RequestParam(required = false) String param) { final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); return new HttpEntity<>(param == null ? "\"json string\"" : "illegal json", headers); }
From source file:com.github.dactiv.fear.service.web.SystemCommonController.java
/** * ?????/* w w w.j a v a 2 s . c o m*/ * * @param token ?? * * @return ?? byte * * @throws IOException */ @RequestMapping("get-captcha") public ResponseEntity<byte[]> getCaptcha(JpegImgCaptchaToken token, HttpSession session) throws IOException { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_JPEG); captchaManager.setCurrentSession(session); Captcha captcha = captchaManager.create(token); return new ResponseEntity<>(captcha.getStream(), headers, HttpStatus.OK); }