org.springframework.http.HttpHeaders.set()

Here are the examples of the java api org.springframework.http.HttpHeaders.set() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

640 Examples 7

19 View Source File : DefaultServerResponseBuilderTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void headers() {
    HttpHeaders newHeaders = new HttpHeaders();
    newHeaders.set("foo", "bar");
    ServerResponse response = ServerResponse.ok().headers(headers -> headers.addAll(newHeaders)).build();
    replacedertEquals(newHeaders, response.headers());
}

19 View Source File : DefaultEntityResponseBuilderTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void headers() {
    String body = "foo";
    HttpHeaders headers = new HttpHeaders();
    headers.set("foo", "bar");
    EnreplacedyResponse<String> result = EnreplacedyResponse.fromObject(body).headers(h -> h.addAll(headers)).build();
    replacedertEquals(headers, result.headers());
}

19 View Source File : NorthboundServiceV2Impl.java
License : Apache License 2.0
Project Creator : telstra

private HttpHeaders buildHeadersWithCorrelationId() {
    HttpHeaders headers = new HttpHeaders();
    headers.set(Utils.CORRELATION_ID, "fn-tests-" + UUID.randomUUID().toString());
    return headers;
}

19 View Source File : UserControllerTest.java
License : MIT License
Project Creator : mariazevedo88

@BeforeAll
private void setUp() {
    headers = new HttpHeaders();
    headers.set("X-api-key", "FX001-ZBSY6YSLP");
}

19 View Source File : Tr069Controller.java
License : MIT License
Project Creator : freeacs

private HttpHeaders getSOAPActionHeader() {
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.set("SOAPAction", "");
    return responseHeaders;
}

19 View Source File : VolumeTest.java
License : GNU General Public License v3.0
Project Creator : fogbow

private HttpHeaders getHttpHeaders() {
    HttpHeaders headers = new HttpHeaders();
    headers.set(CommonKeys.SYSTEM_USER_TOKEN_HEADER_KEY, FAKE_FEDERATION_TOKEN_VALUE);
    return headers;
}

19 View Source File : SecurityRuleInstanceAPITest.java
License : GNU General Public License v3.0
Project Creator : fogbow

private HttpHeaders getHttpHeaders() {
    HttpHeaders headers = new HttpHeaders();
    String fakeUserToken = "fake-access-id";
    headers.set(CommonKeys.SYSTEM_USER_TOKEN_HEADER_KEY, fakeUserToken);
    return headers;
}

19 View Source File : PublicIpTest.java
License : GNU General Public License v3.0
Project Creator : fogbow

private HttpHeaders getHttpHeaders() {
    HttpHeaders headers = new HttpHeaders();
    String userToken = FAKE_USER_TOKEN;
    headers.set(CommonKeys.SYSTEM_USER_TOKEN_HEADER_KEY, userToken);
    return headers;
}

19 View Source File : PolicyEvaluationWithAttributeConnectorIT.java
License : Apache License 2.0
Project Creator : eclipse

private HttpHeaders zoneHeader() throws IOException {
    HttpHeaders httpHeaders = ACSTestUtil.httpHeaders();
    httpHeaders.set(PolicyHelper.PREDIX_ZONE_ID, this.zone.getSubdomain());
    return httpHeaders;
}

19 View Source File : HttpHeaderBuilder.java
License : Apache License 2.0
Project Creator : covid-be-app

public HttpHeaderBuilder resultChannel(String resultChannel) {
    headers.set("Result-Channel", resultChannel);
    return this;
}

19 View Source File : HttpHeaderBuilder.java
License : Apache License 2.0
Project Creator : covid-be-app

public HttpHeaderBuilder randomString(String randomString) {
    headers.set("Random-String", randomString);
    return this;
}

19 View Source File : HttpHeaderBuilder.java
License : Apache License 2.0
Project Creator : covid-be-app

public HttpHeaderBuilder secretKey(String secretKey) {
    headers.set("Secret-Key", secretKey);
    return this;
}

18 View Source File : SignFilter.java
License : MIT License
Project Creator : xk11961677

/**
 * 验证签名
 *
 * @param headers
 * @param messageReq
 * @return
 */
private boolean verifySignature(HttpHeaders headers, MessageReq messageReq) {
    String clientId = messageReq.getClientId();
    headers.set(CLIENT_ID, clientId);
    Map<String, String> clientSecret = gatewayProperties.getSignClientSecret();
    String secret = clientSecret.getOrDefault(clientId, DEFAULT_SECRET);
    boolean verify = verifier.verify(messageReq, secret);
    return verify;
}

18 View Source File : FrontUtils.java
License : Apache License 2.0
Project Creator : WeBankFinTech

public static HttpHeaders headers(String fileName) {
    HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
    httpHeaders.set(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename*=UTF-8''" + encode(fileName));
    return httpHeaders;
}

18 View Source File : DefaultRenderingResponseTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void headers() throws Exception {
    HttpHeaders headers = new HttpHeaders();
    headers.set("foo", "bar");
    RenderingResponse result = RenderingResponse.create("foo").headers(h -> h.addAll(headers)).build();
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    ModelAndView mav = result.writeTo(request, response, EMPTY_CONTEXT);
    replacedertNotNull(mav);
    replacedertEquals("bar", response.getHeader("foo"));
}

18 View Source File : RestTemplateIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void exchangePost() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("MyHeader", "MyValue");
    requestHeaders.setContentType(MediaType.TEXT_PLAIN);
    HttpEnreplacedy<String> enreplacedy = new HttpEnreplacedy<>(helloWorld, requestHeaders);
    HttpEnreplacedy<Void> result = template.exchange(baseUrl + "/{method}", POST, enreplacedy, Void.clreplaced, "post");
    replacedertEquals("Invalid location", new URI(baseUrl + "/post/1"), result.getHeaders().getLocation());
    replacedertFalse(result.hasBody());
}

18 View Source File : RestTemplateIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void exchangeGet() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("MyHeader", "MyValue");
    HttpEnreplacedy<String> requestEnreplacedy = new HttpEnreplacedy<>(requestHeaders);
    ResponseEnreplacedy<String> response = template.exchange(baseUrl + "/{method}", HttpMethod.GET, requestEnreplacedy, String.clreplaced, "get");
    replacedertEquals("Invalid content", helloWorld, response.getBody());
}

18 View Source File : AsyncRestTemplateIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void exchangePost() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("MyHeader", "MyValue");
    requestHeaders.setContentType(MediaType.TEXT_PLAIN);
    HttpEnreplacedy<String> requestEnreplacedy = new HttpEnreplacedy<>(helloWorld, requestHeaders);
    Future<ResponseEnreplacedy<Void>> resultFuture = template.exchange(baseUrl + "/{method}", HttpMethod.POST, requestEnreplacedy, Void.clreplaced, "post");
    ResponseEnreplacedy<Void> result = resultFuture.get();
    replacedertEquals("Invalid location", new URI(baseUrl + "/post/1"), result.getHeaders().getLocation());
    replacedertFalse(result.hasBody());
}

18 View Source File : PrintingResultHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void printRequest() throws Exception {
    this.request.addParameter("param", "paramValue");
    this.request.addHeader("header", "headerValue");
    this.request.setCharacterEncoding("UTF-16");
    String palindrome = "ablE was I ere I saw Elba";
    byte[] bytes = palindrome.getBytes("UTF-16");
    this.request.setContent(bytes);
    this.request.getSession().setAttribute("foo", "bar");
    this.handler.handle(this.mvcResult);
    HttpHeaders headers = new HttpHeaders();
    headers.set("header", "headerValue");
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("param", "paramValue");
    replacedertValue("MockHttpServletRequest", "HTTP Method", this.request.getMethod());
    replacedertValue("MockHttpServletRequest", "Request URI", this.request.getRequestURI());
    replacedertValue("MockHttpServletRequest", "Parameters", params);
    replacedertValue("MockHttpServletRequest", "Headers", headers);
    replacedertValue("MockHttpServletRequest", "Body", palindrome);
    replacedertValue("MockHttpServletRequest", "Session Attrs", Collections.singletonMap("foo", "bar"));
}

18 View Source File : PrintingResultHandlerTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
public void printRequestWithoutSession() throws Exception {
    this.request.addParameter("param", "paramValue");
    this.request.addHeader("header", "headerValue");
    this.request.setCharacterEncoding("UTF-16");
    String palindrome = "ablE was I ere I saw Elba";
    byte[] bytes = palindrome.getBytes("UTF-16");
    this.request.setContent(bytes);
    this.handler.handle(this.mvcResult);
    HttpHeaders headers = new HttpHeaders();
    headers.set("header", "headerValue");
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("param", "paramValue");
    replacedertValue("MockHttpServletRequest", "HTTP Method", this.request.getMethod());
    replacedertValue("MockHttpServletRequest", "Request URI", this.request.getRequestURI());
    replacedertValue("MockHttpServletRequest", "Parameters", params);
    replacedertValue("MockHttpServletRequest", "Headers", headers);
    replacedertValue("MockHttpServletRequest", "Body", palindrome);
}

18 View Source File : UserController.java
License : Apache License 2.0
Project Creator : Tanzu-Solutions-Engineering

private HttpHeaders getNoCacheHeaders() {
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.set("Cache-Control", "no-cache");
    return responseHeaders;
}

18 View Source File : QuoteV1Controller.java
License : Apache License 2.0
Project Creator : Tanzu-Solutions-Engineering

/**
 * Generates HttpHeaders that have the no-cache set.
 *
 * @return HttpHeaders.
 */
private HttpHeaders getNoCacheHeaders() {
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.set("Cache-Control", "no-cache");
    return responseHeaders;
}

18 View Source File : GcpComputeAuthentication.java
License : Apache License 2.0
Project Creator : spring-projects

private static HttpHeaders getMetadataHttpHeaders() {
    HttpHeaders headers = new HttpHeaders();
    headers.set("Metadata-Flavor", "Google");
    return headers;
}

18 View Source File : ProxyProperties.java
License : Apache License 2.0
Project Creator : spring-cloud

public HttpHeaders convertHeaders() {
    HttpHeaders headers = new HttpHeaders();
    for (String key : this.headers.keySet()) {
        headers.set(key, this.headers.get(key));
    }
    return headers;
}

18 View Source File : DefaultServerResponseBuilderTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void headers() {
    HttpHeaders newHeaders = new HttpHeaders();
    newHeaders.set("foo", "bar");
    ServerResponse response = ServerResponse.ok().headers(headers -> headers.addAll(newHeaders)).build();
    replacedertThat(response.headers()).isEqualTo(newHeaders);
}

18 View Source File : DefaultEntityResponseBuilderTests.java
License : Apache License 2.0
Project Creator : SourceHot

@Test
public void headers() {
    String body = "foo";
    HttpHeaders headers = new HttpHeaders();
    headers.set("foo", "bar");
    EnreplacedyResponse<String> result = EnreplacedyResponse.fromObject(body).headers(h -> h.addAll(headers)).build();
    replacedertThat(result.headers()).isEqualTo(headers);
}

18 View Source File : SpringRESTClientConnector.java
License : Apache License 2.0
Project Creator : odpi

/**
 * Create the HTTP header for basic authorization.
 *
 * @param username userId of the caller
 * @param preplacedword preplacedword of the caller
 * @return HTTPHeaders object
 */
private HttpHeaders createHeaders(String username, String preplacedword) {
    String authorizationString = username + ":" + preplacedword;
    byte[] encodedAuthorizationString = Base64.encodeBase64(authorizationString.getBytes(StandardCharsets.US_ASCII));
    String authHeader = "Basic " + new String(encodedAuthorizationString);
    HttpHeaders header = new HttpHeaders();
    header.set("Authorization", authHeader);
    return header;
}

18 View Source File : RangerSecurityServiceConnector.java
License : Apache License 2.0
Project Creator : odpi

private HttpHeaders getHttpHeaders() {
    HttpHeaders headers = getBasicHTTPHeaders();
    if (connection != null && connection.getConfigurationProperties() != null && connection.getConfigurationProperties().containsKey(SECURITY_SERVER_AUTHORIZATION)) {
        headers.set("Authorization", (String) connection.getConfigurationProperties().get(SECURITY_SERVER_AUTHORIZATION));
    }
    return headers;
}

18 View Source File : TravelsJavaApiIntegrationTest.java
License : MIT License
Project Creator : mariazevedo88

@Test
@Order(5)
public void testCreateTravelOrderNumber258963() throws ParseException {
    // id=2
    TravelDTO dtoNsu258963 = new TravelDTO(null, "258963", TravelsApiUtil.getLocalDateTimeFromString("2020-08-21T18:32:04.150Z"), null, new BigDecimal(2546.93), TravelTypeEnum.ONE_WAY.getValue(), 1L);
    final HttpHeaders headers = new HttpHeaders();
    headers.set("X-api-key", "FX001-ZBSY6YSLP");
    // Create a new HttpEnreplacedy
    final HttpEnreplacedy<TravelDTO> enreplacedy = new HttpEnreplacedy<>(dtoNsu258963, headers);
    ResponseEnreplacedy<String> responseEnreplacedy = this.restTemplate.exchange("http://localhost:" + port + "/api-travels/v1/travels", HttpMethod.POST, enreplacedy, String.clreplaced);
    replacedertEquals(201, responseEnreplacedy.getStatusCodeValue());
}

18 View Source File : TravelsJavaApiIntegrationTest.java
License : MIT License
Project Creator : mariazevedo88

@Test
@Order(4)
public void testCreateTravelOrderNumber123456() throws ParseException {
    // id=1
    TravelDTO dtoNsu123456 = new TravelDTO(null, "123456", TravelsApiUtil.getLocalDateTimeFromString("2020-08-15T18:32:04.150Z"), TravelsApiUtil.getLocalDateTimeFromString("2020-08-21T18:32:04.150Z"), new BigDecimal(100d), TravelTypeEnum.RETURN.getValue(), 1L);
    final HttpHeaders headers = new HttpHeaders();
    headers.set("X-api-key", "FX001-ZBSY6YSLP");
    // Create a new HttpEnreplacedy
    final HttpEnreplacedy<TravelDTO> enreplacedy = new HttpEnreplacedy<>(dtoNsu123456, headers);
    ResponseEnreplacedy<String> responseEnreplacedy = this.restTemplate.exchange("http://localhost:" + port + "/api-travels/v1/travels", HttpMethod.POST, enreplacedy, String.clreplaced);
    replacedertEquals(201, responseEnreplacedy.getStatusCodeValue());
}

18 View Source File : HeaderUtil.java
License : MIT License
Project Creator : ls1intum

/**
 * Creates a authorization headers for a given token
 * @param token the token for the authorization
 * @return the acceptHeader
 */
public static HttpHeaders createAuthorization(String token) {
    HttpHeaders authorizationHeaders = new HttpHeaders() {

        {
            set(com.google.common.net.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
            set(com.google.common.net.HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
        }
    };
    authorizationHeaders.set("Authorization", "Bearer " + token);
    return authorizationHeaders;
}

18 View Source File : HeaderUtil.java
License : MIT License
Project Creator : ls1intum

/**
 * Creates a authorization headers for a given username and preplacedword
 * @param username the username for the authentication
 * @param preplacedword the preplacedword for the authentication
 * @return the authorization header
 */
public static HttpHeaders createAuthorization(String username, String preplacedword) {
    HttpHeaders authorizationHeaders = new HttpHeaders() {

        {
            set(com.google.common.net.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString());
            set(com.google.common.net.HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString());
        }
    };
    String authorization = username + ":" + preplacedword;
    String basic = new String(Base64.getEncoder().encode(authorization.getBytes(StandardCharsets.UTF_8)));
    authorizationHeaders.set("Authorization", "Basic " + basic);
    return authorizationHeaders;
}

18 View Source File : RemoteArtemisServiceConnector.java
License : MIT License
Project Creator : ls1intum

/**
 * Helper to generate HttpHeaders for a symmetric secret.
 *
 * @param secret Authorization secret
 * @return HttpHeaders
 */
static HttpHeaders authorizationHeaderForSymmetricSecret(String secret) {
    HttpHeaders headers = new HttpHeaders();
    headers.set("Authorization", secret);
    return headers;
}

18 View Source File : RestTemplateIntegrationTests.java
License : Apache License 2.0
Project Creator : langtianya

@Test
public void exchangePost() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("MyHeader", "MyValue");
    requestHeaders.setContentType(MediaType.TEXT_PLAIN);
    HttpEnreplacedy<String> requestEnreplacedy = new HttpEnreplacedy<String>(helloWorld, requestHeaders);
    HttpEnreplacedy<Void> result = template.exchange(baseUrl + "/{method}", HttpMethod.POST, requestEnreplacedy, Void.clreplaced, "post");
    replacedertEquals("Invalid location", new URI(baseUrl + "/post/1"), result.getHeaders().getLocation());
    replacedertFalse(result.hasBody());
}

18 View Source File : RestTemplateIntegrationTests.java
License : Apache License 2.0
Project Creator : langtianya

@Test
public void exchangeGet() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("MyHeader", "MyValue");
    HttpEnreplacedy<String> requestEnreplacedy = new HttpEnreplacedy<String>(requestHeaders);
    ResponseEnreplacedy<String> response = template.exchange(baseUrl + "/{method}", HttpMethod.GET, requestEnreplacedy, String.clreplaced, "get");
    replacedertEquals("Invalid content", helloWorld, response.getBody());
}

18 View Source File : AsyncRestTemplateIntegrationTests.java
License : Apache License 2.0
Project Creator : langtianya

@Test
public void exchangePost() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("MyHeader", "MyValue");
    requestHeaders.setContentType(MediaType.TEXT_PLAIN);
    HttpEnreplacedy<String> requestEnreplacedy = new HttpEnreplacedy<String>(helloWorld, requestHeaders);
    Future<ResponseEnreplacedy<Void>> resultFuture = template.exchange(baseUrl + "/{method}", HttpMethod.POST, requestEnreplacedy, Void.clreplaced, "post");
    ResponseEnreplacedy<Void> result = resultFuture.get();
    replacedertEquals("Invalid location", new URI(baseUrl + "/post/1"), result.getHeaders().getLocation());
    replacedertFalse(result.hasBody());
}

18 View Source File : PrintingResultHandlerTests.java
License : Apache License 2.0
Project Creator : langtianya

@Test
public void printRequest() throws Exception {
    this.request.addParameter("param", "paramValue");
    this.request.addHeader("header", "headerValue");
    this.handler.handle(this.mvcResult);
    HttpHeaders headers = new HttpHeaders();
    headers.set("header", "headerValue");
    MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
    params.add("param", "paramValue");
    replacedertValue("MockHttpServletRequest", "HTTP Method", this.request.getMethod());
    replacedertValue("MockHttpServletRequest", "Request URI", this.request.getRequestURI());
    replacedertValue("MockHttpServletRequest", "Parameters", params);
    replacedertValue("MockHttpServletRequest", "Headers", headers);
}

18 View Source File : UserContext.java
License : MIT License
Project Creator : ihuaylupo

public static HttpHeaders getHttpHeaders() {
    HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.set(CORRELATION_ID, getCorrelationId());
    return httpHeaders;
}

18 View Source File : RestClient.java
License : Apache License 2.0
Project Creator : Hygieia

protected HttpHeaders createHeaders(String user) {
    byte[] encodedAuth = Base64.encodeBase64(user.getBytes(StandardCharsets.US_ASCII));
    String authHeader = "Basic " + new String(encodedAuth);
    HttpHeaders headers = new HttpHeaders();
    headers.set("Authorization", authHeader);
    return headers;
}

18 View Source File : RestClient.java
License : Apache License 2.0
Project Creator : Hygieia

protected HttpHeaders createHeaders(String key, String token) {
    String authHeader = key.trim() + " " + token.trim();
    HttpHeaders headers = new HttpHeaders();
    headers.set("Authorization", authHeader);
    return headers;
}

18 View Source File : RestApiSecurityApplicationTest.java
License : Apache License 2.0
Project Creator : flowable

protected static HttpHeaders createHeaders(String username, String preplacedword) {
    HttpHeaders headers = new HttpHeaders();
    headers.set(HttpHeaders.AUTHORIZATION, base64Authentication(username, preplacedword));
    return headers;
}

18 View Source File : FlowableRestApplicationSecurityTest.java
License : Apache License 2.0
Project Creator : flowable

protected static HttpHeaders createHeaders(String username, String preplacedword) {
    HttpHeaders headers = new HttpHeaders();
    headers.set(HttpHeaders.AUTHORIZATION, base64Auhentication(username, preplacedword));
    return headers;
}

18 View Source File : ResponseUtils.java
License : MIT License
Project Creator : fengdis

public static ResponseEnreplacedy<String> jsonResult(String result) {
    HttpHeaders resHeaders = new HttpHeaders();
    resHeaders.set("Content-Type", CONTENT_TYPE_FOR_JSON + ";charset=UTF-8");
    return new ResponseEnreplacedy<String>(result, resHeaders, HttpStatus.OK);
}

18 View Source File : ApmService.java
License : Apache License 2.0
Project Creator : EdgeGallery

/**
 * Sends post request.
 *
 * @param url         URL
 * @param reqBody     request body
 * @param accessToken access token
 * @throws ApmException exception if failed to delete
 */
public void sendPostRequest(String url, String reqBody, String accessToken) {
    LOGGER.info("POST request: {}", url);
    ResponseEnreplacedy<String> response;
    try {
        HttpHeaders headers = new HttpHeaders();
        headers.set("access_token", accessToken);
        HttpEnreplacedy<String> enreplacedy = new HttpEnreplacedy<>(reqBody, headers);
        response = restTemplate.exchange(url, HttpMethod.POST, enreplacedy, String.clreplaced);
    } catch (ResourceAccessException ex) {
        LOGGER.error("connection failed {}", ex.getMessage());
        throw new ApmException("failed to connect " + ex.getMessage());
    } catch (HttpClientErrorException | HttpServerErrorException ex) {
        LOGGER.error("failed {}", ex.getMessage());
        throw new ApmException("error while delete " + ex.getMessage());
    }
    if (HttpStatus.NOT_FOUND.equals(response.getStatusCode())) {
        LOGGER.error("data not found, status {}", response.getStatusCode());
        throw new NoSuchElementException("not found status " + response.getStatusCode());
    }
    if (!HttpStatus.OK.equals(response.getStatusCode())) {
        LOGGER.error("received failure response status {}", response.getStatusCode());
        throw new ApmException("received failure response status " + response.getStatusCode());
    }
}

18 View Source File : ApmService.java
License : Apache License 2.0
Project Creator : EdgeGallery

/**
 * Sends delete request.
 *
 * @param url         URL
 * @param accessToken access token
 * @throws ApmException exception if failed to delete
 */
public void sendDeleteRequest(String url, String accessToken) {
    LOGGER.info("DELETE request: {}", url);
    ResponseEnreplacedy<String> response;
    try {
        HttpHeaders headers = new HttpHeaders();
        headers.set("access_token", accessToken);
        HttpEnreplacedy<String> enreplacedy = new HttpEnreplacedy<>(headers);
        response = restTemplate.exchange(url, HttpMethod.DELETE, enreplacedy, String.clreplaced);
    } catch (ResourceAccessException ex) {
        LOGGER.error("connection failed {}", ex.getMessage());
        throw new ApmException("failed to connect " + ex.getMessage());
    } catch (HttpClientErrorException ex) {
        LOGGER.error("failed {}", ex.getMessage());
        throw new ApmException("error while delete " + ex.getMessage());
    }
    if (HttpStatus.NOT_FOUND.equals(response.getStatusCode())) {
        LOGGER.error("data not found, status {}", response.getStatusCode());
        throw new NoSuchElementException("not found status " + response.getStatusCode());
    }
    if (!HttpStatus.OK.equals(response.getStatusCode())) {
        LOGGER.error("received failure response status {}", response.getStatusCode());
        throw new ApmException("received failure response status " + response.getStatusCode());
    }
}

18 View Source File : RestTemplateRequest.java
License : Apache License 2.0
Project Creator : crnk-project

@Override
public void header(String name, String value) {
    headers.set(name, value);
}

18 View Source File : ApplicationApi.java
License : Apache License 2.0
Project Creator : codeabovelab

@RequestMapping(value = "{cluster}/{appId}/initFile", method = GET, produces = APPLICATION_OCTET_STREAM_VALUE)
public ResponseEnreplacedy<Resource> getInitFile(@PathVariable("cluster") String cluster, @PathVariable("appId") String appId) {
    File initComposeFile = applicationService.getInitComposeFile(cluster, appId);
    log.info("fetching config file for application: {}, cluster: {}, path {}", appId, cluster, initComposeFile);
    if (!initComposeFile.exists()) {
        throw new NotFoundException("file not found " + initComposeFile);
    }
    HttpHeaders respHeaders = new HttpHeaders();
    respHeaders.set("Content-Disposition", "attachment; filename=" + initComposeFile.getName());
    respHeaders.setContentLength(initComposeFile.length());
    return new ResponseEnreplacedy<>(new PathResource(initComposeFile.toPath()), respHeaders, HttpStatus.OK);
}

18 View Source File : FinTechAuthorizationImpl.java
License : Apache License 2.0
Project Creator : adorsys

@Override
public ResponseEnreplacedy<Void> logoutPOST(UUID xRequestID, String xsrfToken) {
    log.debug("logoutPost is called for {}", restRequestContext);
    if (!sessionLogicService.isSessionAuthorized()) {
        log.warn("logoutPOST failed: user is not authorized!");
        return new ResponseEnreplacedy<>(HttpStatus.UNAUTHORIZED);
    }
    authorizeService.logout();
    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.set(X_REQUEST_ID, restRequestContext.getRequestId());
    return new ResponseEnreplacedy<>(null, responseHeaders, HttpStatus.OK);
}

18 View Source File : ProcessDefinitionIT.java
License : Apache License 2.0
Project Creator : Activiti

private <T> T executeRequest(String url, HttpMethod method, String contentType, Clreplaced<T> javaType) {
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", contentType);
    ResponseEnreplacedy<T> response = restTemplate.exchange(url, method, new HttpEnreplacedy<>(headers), javaType);
    replacedertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
    return response.getBody();
}

17 View Source File : AsyncRestTemplateIntegrationTests.java
License : MIT License
Project Creator : Vip-Augus

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void exchangeGetCallbackWithLambdas() throws Exception {
    HttpHeaders requestHeaders = new HttpHeaders();
    requestHeaders.set("MyHeader", "MyValue");
    HttpEnreplacedy<?> requestEnreplacedy = new HttpEnreplacedy(requestHeaders);
    ListenableFuture<ResponseEnreplacedy<String>> responseFuture = template.exchange(baseUrl + "/{method}", HttpMethod.GET, requestEnreplacedy, String.clreplaced, "get");
    responseFuture.addCallback(result -> replacedertEquals("Invalid content", helloWorld, result.getBody()), ex -> fail(ex.getMessage()));
    waitTillDone(responseFuture);
}

See More Examples