Skip to content

Commit

Permalink
Fix a regression in HttpServerRequest#isExpectMultipart due to the cl…
Browse files Browse the repository at this point in the history
…eanup of the form.
  • Loading branch information
vietj committed Mar 25, 2024
1 parent b543b26 commit 8db4ac8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class Http1xServerRequest extends HttpServerRequestInternal implements io
private HttpEventHandler eventHandler;
private Handler<HttpServerFileUpload> uploadHandler;
private MultiMap attributes;
private boolean expectMultipart;
private HttpPostRequestDecoder decoder;
private boolean ended;
private long bytesRead;
Expand Down Expand Up @@ -483,6 +484,7 @@ private void webSocket(PromiseInternal<ServerWebSocket> promise) {
public HttpServerRequest setExpectMultipart(boolean expect) {
synchronized (conn) {
checkEnded();
expectMultipart = expect;
if (expect) {
if (decoder == null) {
String contentType = request.headers().get(HttpHeaderNames.CONTENT_TYPE);
Expand Down Expand Up @@ -510,10 +512,8 @@ public HttpServerRequest setExpectMultipart(boolean expect) {
}

@Override
public boolean isExpectMultipart() {
synchronized (conn) {
return decoder != null;
}
public synchronized boolean isExpectMultipart() {
return expectMultipart;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Http2ServerRequest extends HttpServerRequestInternal implements Htt
private HttpEventHandler eventHandler;
private boolean ended;
private Handler<HttpServerFileUpload> uploadHandler;
private boolean expectMultipart;
private HttpPostRequestDecoder postRequestDecoder;
private Handler<HttpFrame> customFrameHandler;
private Handler<StreamPriority> streamPriorityHandler;
Expand Down Expand Up @@ -401,6 +402,7 @@ public Future<NetSocket> toNetSocket() {
public HttpServerRequest setExpectMultipart(boolean expect) {
synchronized (stream.conn) {
checkEnded();
expectMultipart = expect;
if (expect) {
if (postRequestDecoder == null) {
String contentType = headersMap.get(HttpHeaderNames.CONTENT_TYPE);
Expand Down Expand Up @@ -435,7 +437,7 @@ public HttpServerRequest setExpectMultipart(boolean expect) {
@Override
public boolean isExpectMultipart() {
synchronized (stream.conn) {
return postRequestDecoder != null;
return expectMultipart;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ private void testFormUploadFile(String filename,
req.endHandler(v -> {
MultiMap attrs = req.formAttributes();
attributeCount.set(attrs.size());
assertTrue(req.isExpectMultipart());
req.response().end();
});
}
Expand Down

0 comments on commit 8db4ac8

Please sign in to comment.