Skip to content

Commit

Permalink
fix: improve error message in case http method is missing (fixes #19063)
Browse files Browse the repository at this point in the history
  • Loading branch information
deki committed Jan 10, 2022
1 parent 863020d commit 151897a
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,16 @@ private APIGatewayV2HTTPResponse nettyDispatch(InetSocketAddress clientAddress,
quarkusHeaders.setContextObject(Context.class, context);
quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.class, request);
quarkusHeaders.setContextObject(APIGatewayV2HTTPEvent.RequestContext.class, request.getRequestContext());
HttpMethod httpMethod = null;
if (request.getRequestContext() != null && request.getRequestContext().getHttp() != null
&& request.getRequestContext().getHttp().getMethod() != null) {
httpMethod = HttpMethod.valueOf(request.getRequestContext().getHttp().getMethod());
}
if (httpMethod == null) {
throw new IllegalStateException("Missing HTTP method in request event");
}
DefaultHttpRequest nettyRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
HttpMethod.valueOf(request.getRequestContext().getHttp().getMethod()), ofNullable(request.getRawQueryString())
httpMethod, ofNullable(request.getRawQueryString())
.filter(q -> !q.isEmpty()).map(q -> request.getRawPath() + '?' + q).orElse(request.getRawPath()),
quarkusHeaders);
if (request.getHeaders() != null) { //apparently this can be null if no headers are sent
Expand Down

0 comments on commit 151897a

Please sign in to comment.