Example usage for org.springframework.http RequestEntity getMethod

List of usage examples for org.springframework.http RequestEntity getMethod

Introduction

In this page you can find the example usage for org.springframework.http RequestEntity getMethod.

Prototype

@Nullable
public HttpMethod getMethod() 

Source Link

Document

Return the HTTP method of the request.

Usage

From source file:org.cloudfoundry.example.Controller.java

private static RequestEntity<?> getOutgoingRequest(RequestEntity<?> incoming) {
    HttpHeaders headers = new HttpHeaders();
    headers.putAll(incoming.getHeaders());

    URI uri = headers.remove(FORWARDED_URL).stream().findFirst().map(URI::create)
            .orElseThrow(() -> new IllegalStateException(String.format("No %s header present", FORWARDED_URL)));

    return new RequestEntity<>(incoming.getBody(), headers, incoming.getMethod(), uri);
}

From source file:io.pivotalservices.wiretaprouteservice.CatchAllController.java

private static RequestEntity<?> getOutgoingRequest(RequestEntity<?> incoming) {
    HttpHeaders headers = new HttpHeaders();
    headers.putAll(incoming.getHeaders());
    URI uri = headers.remove(FORWARDED_URL).stream().findFirst().map(URI::create)
            .orElseThrow(() -> new IllegalStateException(String.format("No %s header present", FORWARDED_URL)));
    return new RequestEntity<>(incoming.getBody(), headers, incoming.getMethod(), uri);
}

From source file:org.zalando.stups.oauth2.spring.server.TokenInfoResourceServerTokenServicesTest.java

@Test
public void buildRequest() {

    RequestEntity<Void> entity = DefaultTokenInfoRequestExecutor.buildRequestEntity(URI.create(TOKENINFO_URL),
            "0123456789");

    Assertions.assertThat(entity).isNotNull();

    Assertions.assertThat(entity.getMethod()).isEqualTo(HttpMethod.GET);
    Assertions.assertThat(entity.getUrl()).isEqualTo(URI.create(TOKENINFO_URL));

    Assertions.assertThat(entity.getHeaders()).containsKey(HttpHeaders.AUTHORIZATION);
    List<String> authorizationHeader = entity.getHeaders().get(HttpHeaders.AUTHORIZATION);
    Assertions.assertThat(authorizationHeader).containsExactly("Bearer 0123456789");

    Assertions.assertThat(entity.getHeaders()).containsKey(HttpHeaders.ACCEPT);
    Assertions.assertThat(entity.getHeaders().getAccept()).contains(MediaType.APPLICATION_JSON);
}

From source file:org.springframework.boot.test.web.client.TestRestTemplate.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private RequestEntity<?> createRequestEntityWithRootAppliedUri(RequestEntity<?> requestEntity) {
    return new RequestEntity(requestEntity.getBody(), requestEntity.getHeaders(), requestEntity.getMethod(),
            applyRootUriIfNecessary(requestEntity.getUrl()), requestEntity.getType());
}