use of org.springframework.http.HttpHeaders in project spring-framework by spring-projects.
the class DefaultClientResponseTests method bodyToMonoError.
@Test
public void bodyToMonoError() throws Exception {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.TEXT_PLAIN);
when(mockResponse.getHeaders()).thenReturn(httpHeaders);
when(mockResponse.getStatusCode()).thenReturn(HttpStatus.NOT_FOUND);
Set<HttpMessageReader<?>> messageReaders = Collections.singleton(new DecoderHttpMessageReader<String>(new StringDecoder()));
when(mockExchangeStrategies.messageReaders()).thenReturn(messageReaders::stream);
Mono<String> resultMono = defaultClientResponse.bodyToMono(String.class);
StepVerifier.create(resultMono).expectError(WebClientException.class).verify();
}
use of org.springframework.http.HttpHeaders in project spring-framework by spring-projects.
the class CrossOriginAnnotationIntegrationTests method setup.
@Before
public void setup() throws Exception {
super.setup();
this.headers = new HttpHeaders();
this.headers.setOrigin("http://site1.com");
}
use of org.springframework.http.HttpHeaders in project spring-framework by spring-projects.
the class CrossOriginAnnotationIntegrationTests method actualRequestWithDefaultAnnotationAndNoOrigin.
@Test
public void actualRequestWithDefaultAnnotationAndNoOrigin() throws Exception {
HttpHeaders headers = new HttpHeaders();
ResponseEntity<String> entity = performGet("/default", headers, String.class);
assertEquals(HttpStatus.OK, entity.getStatusCode());
assertNull(entity.getHeaders().getAccessControlAllowOrigin());
assertEquals("default", entity.getBody());
}
use of org.springframework.http.HttpHeaders in project spring-framework by spring-projects.
the class GlobalCorsConfigIntegrationTests method setup.
@Before
public void setup() throws Exception {
super.setup();
this.headers = new HttpHeaders();
this.headers.setOrigin("http://localhost:9000");
}
use of org.springframework.http.HttpHeaders in project spring-framework by spring-projects.
the class WebSocketIntegrationTests method customHeader.
@Test
public void customHeader() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.add("my-header", "my-value");
MonoProcessor<Object> output = MonoProcessor.create();
client.execute(getUrl("/custom-header"), headers, session -> session.receive().map(WebSocketMessage::getPayloadAsText).subscribeWith(output).then()).block(Duration.ofMillis(5000));
assertEquals("my-header:my-value", output.block(Duration.ofMillis(5000)));
}
Aggregations