List of usage examples for org.springframework.http HttpHeaders add
@Override public void add(String headerName, @Nullable String headerValue)
From source file:com.mycompany.trader.TradingConnect.java
private static void loginAndSaveJsessionIdCookie(final String user, final String password, final HttpHeaders headersToUpdate) { String url = "http://localhost:" + port + "/blueprint-trading-services/login.html"; new RestTemplate().execute(url, HttpMethod.POST, new RequestCallback() { @Override//from www . j a v a 2 s . c o m public void doWithRequest(ClientHttpRequest request) throws IOException { MultiValueMap<String, String> map = new LinkedMultiValueMap<>(); map.add("username", user); map.add("password", password); new FormHttpMessageConverter().write(map, MediaType.APPLICATION_FORM_URLENCODED, request); } }, new ResponseExtractor<Object>() { @Override public Object extractData(ClientHttpResponse response) throws IOException { headersToUpdate.add("Cookie", response.getHeaders().getFirst("Set-Cookie")); return null; } }); }
From source file:restTemplateConfiguration.userAgentInterceptor.java
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpHeaders headers = request.getHeaders(); headers.add("User-Agent", "Mozilla/5.0"); return execution.execute(request, body); }
From source file:com.github.moscaville.contactsdb.util.AirtableAuthorizationInterceptor.java
@Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpHeaders headers = request.getHeaders(); headers.add("Authorization", "Bearer " + AIRTABLE_API_KEY); return execution.execute(request, body); }
From source file:com.isalnikov.controller.MessageController.java
@RequestMapping(value = { "/message/{code}" }, method = RequestMethod.GET) @ResponseBody/*from w w w.j a va2 s . co m*/ public ResponseEntity index(@PathVariable("code") String code, Locale locale) { String result = messageSource.getMessage(code, new Object[] {}, locale); System.out.println(String.format("%s : %s", locale.getLanguage(), result)); String res = String.format("%s : %s", locale.getLanguage(), messageHelper.getMessage(code)); HttpHeaders headers = new HttpHeaders(); headers.add("Content-type", "application/json;charset=UTF-8"); ResponseEntity responseEntity = new ResponseEntity<>(res, headers, HttpStatus.OK); return responseEntity; }
From source file:pw.spn.mptg.controller.ProjectTemplateController.java
@PostMapping(produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) public ResponseEntity<byte[]> generate(@ModelAttribute PomTemplate pomTemplate) { HttpHeaders headers = new HttpHeaders(); headers.add(HttpHeaders.CONTENT_DISPOSITION, String.format(CONTENT_DISPOSITION_VALUE, pomTemplate.getArtifactId())); ResponseEntity<byte[]> responseEntity = new ResponseEntity<byte[]>( projectService.generateProjectAndZip(pomTemplate), headers, HttpStatus.OK); return responseEntity; }
From source file:com.appglu.impl.GZipHttpRequestInterceptor.java
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { HttpRequestWrapper wrapper = new HttpRequestWrapper(request) { @Override//from w w w. j a va 2s .co m public HttpHeaders getHeaders() { HttpHeaders headers = super.getHeaders(); headers.add("Accept-Encoding", "gzip"); return headers; } }; return execution.execute(wrapper, body); }
From source file:org.trustedanalytics.servicebroker.gearpump.service.externals.helpers.CfCaller.java
public HttpHeaders createJsonHeaders() { HttpHeaders headers = new HttpHeaders(); headers.add("Accept", "application/json"); headers.add("Content-type", "application/json"); return headers; }
From source file:com.vinidsl.googleioextended.rest.BaseRequest.java
/** * Returns the HttpHeaders to be used in the request. * @return// ww w.j a v a 2 s . com */ public HttpHeaders getHeaders() { HttpHeaders headers = new HttpHeaders(); headers.add("Accept", "application/json"); headers.add("X-Parse-Application-Id", "eOZ0eFf8g2uJuX2xom30uzsTPXjdGc4kvBUXsG7K"); headers.add("X-Parse-REST-API-Key", "Qi8G0MAn090msWUuEchhKtIPzh0tPF8FlxKDRWXJ"); return headers; }
From source file:fi.helsinki.opintoni.integration.unisport.UnisportRestClient.java
private HttpEntity<String> getAuthorizationHeader(final Long unisportUserId) { HttpHeaders headers = new HttpHeaders(); headers.add(AUTHORIZATION_HEADER, unisportJWTService.generateToken(unisportUserId)); return new HttpEntity<>("parameters", headers); }
From source file:com.biz.report.controller.CustomerReportControler.java
@RequestMapping(value = "/customers") private ResponseEntity<List<String>> readCustomers() { HttpHeaders headers = new HttpHeaders(); headers.add("success", "Success"); return new ResponseEntity<List<String>>(customerService.readCustomers(), headers, HttpStatus.OK); }