|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
* Copyright 2012-2023 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -21,8 +21,9 @@ import java.nio.charset.StandardCharsets;
|
|
|
|
import java.util.zip.GZIPInputStream;
|
|
|
|
import java.util.zip.GZIPInputStream;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
|
|
|
|
import smoketest.jetty.util.RandomStringUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
@ -36,7 +37,6 @@ import org.springframework.http.HttpMethod;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.util.StreamUtils;
|
|
|
|
import org.springframework.util.StreamUtils;
|
|
|
|
import smoketest.jetty.util.RandomStringUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
|
|
|
@ -72,6 +72,7 @@ class SampleJettyApplicationTests {
|
|
|
|
HttpEntity<?> requestEntity = new HttpEntity<>(requestHeaders);
|
|
|
|
HttpEntity<?> requestEntity = new HttpEntity<>(requestHeaders);
|
|
|
|
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
|
|
|
|
ResponseEntity<byte[]> entity = this.restTemplate.exchange("/", HttpMethod.GET, requestEntity, byte[].class);
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
|
|
|
|
|
|
|
assertThat(entity.getBody()).isNotNull();
|
|
|
|
try (GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()))) {
|
|
|
|
try (GZIPInputStream inflater = new GZIPInputStream(new ByteArrayInputStream(entity.getBody()))) {
|
|
|
|
assertThat(StreamUtils.copyToString(inflater, StandardCharsets.UTF_8)).isEqualTo("Hello World");
|
|
|
|
assertThat(StreamUtils.copyToString(inflater, StandardCharsets.UTF_8)).isEqualTo("Hello World");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -87,7 +88,7 @@ class SampleJettyApplicationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void testMaxHttpRequestHeaderSize() {
|
|
|
|
void testMaxHttpRequestHeaderSize() {
|
|
|
|
String headerValue = RandomStringUtil.getRandomBase64EncodedString(maxHttpRequestHeaderSize + 1);
|
|
|
|
String headerValue = RandomStringUtil.getRandomBase64EncodedString(this.maxHttpRequestHeaderSize + 1);
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
headers.add("x-max-request-header", headerValue);
|
|
|
|
headers.add("x-max-request-header", headerValue);
|
|
|
|
HttpEntity<?> httpEntity = new HttpEntity<>(headers);
|
|
|
|
HttpEntity<?> httpEntity = new HttpEntity<>(headers);
|
|
|
|