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 eb08504 commit adbe976
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 @@ -93,6 +93,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 @@ -473,6 +474,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 @@ -500,10 +502,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 @@ -64,6 +64,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 @@ -397,6 +398,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 @@ -431,7 +433,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 adbe976

Please sign in to comment.