Skip to content

Commit 17295d8

Browse files
authored
bugfix: undertow has missing request body (#90)
1 parent f1a0bf1 commit 17295d8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

examples/http/requests.http

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### POST request
2+
POST http://localhost:8080/
3+
Content-Type: application/json
4+
5+
{
6+
"name": 1
7+
}
8+
9+
### GET request
10+
GET http://localhost:8080/?fromDate=2020-01-01
11+
12+
### GET request (with body)
13+
GET http://localhost:8080/?fromDate=2020-01-01
14+
Content-Type: application/json
15+
16+
{}

examples/openapi.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ paths:
3535
description: Update index
3636
operationId: postIndex
3737
requestBody:
38-
required: false
38+
required: true
3939
content:
4040
application/json:
4141
schema:

spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/MultiReadContentCachingRequestWrapper.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public MultiReadContentCachingRequestWrapper(HttpServletRequest request, int con
2121

2222
@Override
2323
public ServletInputStream getInputStream() throws IOException {
24-
var inputStream = super.getInputStream();
25-
if (inputStream.isFinished()) {
26-
return new CachedServletInputStream(getContentAsByteArray());
24+
var cachedContent = getContentAsByteArray();
25+
if (cachedContent.length > 0) {
26+
return new CachedServletInputStream(cachedContent);
2727
}
2828

29-
return inputStream;
29+
return super.getInputStream();
3030
}
3131

3232
@Override

0 commit comments

Comments
 (0)