-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the request body limit configurable (and increase the default) #1762
Open
hannahbast
wants to merge
8
commits into
master
Choose a base branch
from
request-size-limit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+32
−19
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d37d1c5
Increase the request size limit
39f3775
set the request body size limit via a runtime parameter
Qup42 bdb6694
move the request out from boost's parser
Qup42 9426593
Merge branch 'master' into request-size-limit
Qup42 feb8d0f
Merge remote-tracking branch 'origin/master' into request-size-limit
0062d9a
Merge remote-tracking branch 'origin/master' into request-size-limit
dd36aff
include HttpServer.h only in Server.cpp
Qup42 ced8150
set default request-body-limit to 100mb
Qup42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
// Copyright 2021, University of Freiburg, | ||
// Chair of Algorithms and Data Structures. | ||
// Author: Johannes Kalmbach <[email protected]> | ||
// Copyright 2021-2025, University of Freiburg, | ||
// Chair of Algorithms and Data Structures | ||
// Authors: Johannes Kalmbach <[email protected]> | ||
// Julian Mundhahs <mundhahj@t | ||
|
||
#ifndef QLEVER_HTTPSERVER_H | ||
#define QLEVER_HTTPSERVER_H | ||
|
@@ -10,6 +10,7 @@ | |
#include <future> | ||
|
||
#include "absl/cleanup/cleanup.h" | ||
#include "global/RuntimeParameters.h" | ||
#include "util/Exception.h" | ||
#include "util/Log.h" | ||
#include "util/http/HttpUtils.h" | ||
|
@@ -245,11 +246,18 @@ CPP_template(typename HttpHandler, typename WebSocketHandler)( | |
try { | ||
// Set the timeout for reading the next request. | ||
stream.expires_after(std::chrono::seconds(30)); | ||
http::request<http::string_body> req; | ||
|
||
// Read a request | ||
co_await http::async_read(stream, buffer, req, | ||
// Read a request. Use a parser so that we can control the limit of the | ||
// request size. | ||
http::request_parser<http::string_body> requestParser; | ||
auto bodyLimit = | ||
RuntimeParameters().get<"request-body-limit">().getBytes(); | ||
requestParser.body_limit(bodyLimit == 0 | ||
? boost::none | ||
: boost::optional<uint64_t>(bodyLimit)); | ||
co_await http::async_read(stream, buffer, requestParser, | ||
boost::asio::use_awaitable); | ||
http::request<http::string_body> req = requestParser.release(); | ||
|
||
// Let request be handled by `WebSocketSession` if the HTTP | ||
// request is a WebSocket handshake | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header is very expensive to include. It would be nice if the implementation could be moved into a cpp file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for having a look. The
HttpServer.h
header is now only included inServer.cpp
so that shouldn't be that much of a problem. The HttpServer unfortunately cannot be moved to a cpp, because the whole class is templated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine too but I was thinking about adding a helper function in a cpp and using it to call the function indirectly