History log of /openbmc/bmcweb/http/http_body.hpp (Results 1 – 12 of 12)
Revision Date Author Comments
# 504af5a0 03-Feb-2025 Patrick Williams <patrick@stwcx.xyz>

clang-format: update latest spec and reformat

Copy the latest format file from the docs repository and apply.

Change-Id: I2f0b9d0fb6e01ed36a2f34c750ba52de3b6d15d1
Signed-off-by: Patrick Williams <p

clang-format: update latest spec and reformat

Copy the latest format file from the docs repository and apply.

Change-Id: I2f0b9d0fb6e01ed36a2f34c750ba52de3b6d15d1
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>

show more ...


# d7857201 28-Jan-2025 Ed Tanous <etanous@nvidia.com>

Fix includes

Clang-tidy misc-include-cleaner appears to now be enforcing
significantly more headers than previously. That is overall a good
thing, but forces us to fix some issues. This commit is

Fix includes

Clang-tidy misc-include-cleaner appears to now be enforcing
significantly more headers than previously. That is overall a good
thing, but forces us to fix some issues. This commit is largely just
taking the clang-recommended fixes and checking them in. Subsequent
patches will fix the more unique issues.

Note, that a number of new ignores are added into the .clang-tidy file.
These can be cleaned up over time as they're understood. The majority
are places where boost includes a impl/x.hpp and x.hpp, but expects you
to use the later. include-cleaner opts for the impl, but it isn't clear
why.

Change-Id: Id3fdd7ee6df6c33b2fd35626898523048dd51bfb
Signed-off-by: Ed Tanous <etanous@nvidia.com>
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>

show more ...


# 40e9b92e 10-Sep-2024 Ed Tanous <etanous@nvidia.com>

Use SPDX identifiers

SPDX identifiers are simpler, and reduce the amount of cruft we have in
code files. They are recommended by linux foundation, and therefore we
should do as they allow.

This pa

Use SPDX identifiers

SPDX identifiers are simpler, and reduce the amount of cruft we have in
code files. They are recommended by linux foundation, and therefore we
should do as they allow.

This patchset does not intend to modify any intent on any existing
copyrights or licenses, only to standardize their inclusion.

[1] https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects

Change-Id: I935c7c0156caa78fc368c929cebd0f068031e830
Signed-off-by: Ed Tanous <etanous@nvidia.com>

show more ...


# bd79bce8 16-Aug-2024 Patrick Williams <patrick@stwcx.xyz>

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda forma

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: Iceec1dc95b6c908ec6c21fb40093de9dd18bf11a
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>

show more ...


# 608fb7b7 09-Aug-2024 Potin Lai <potin.lai@quantatw.com>

http_body: Implement static bmcweb::HttpBody::size() function

In boost::beast::http::message::prepare_payload(), if HttpBody does
not implement a size() function, it defaults to calling chunked(true

http_body: Implement static bmcweb::HttpBody::size() function

In boost::beast::http::message::prepare_payload(), if HttpBody does
not implement a size() function, it defaults to calling chunked(true)
for HTTP/1.1 and chunked(false) for other versions.

We encountered an issue with request data (an extra final chunk) when
`chunked(true)` is called with empty data. To ensure prepare_payload
behaves as expected, we want it to follow the code path that handles the
payload size correctly. Specifically, we want it to:

- Use `content_length(n)` for requests with data.
- Use `chunked(false)` for requests without data.

By adding a static implementation of the bmcweb::HttpBody::size()
function, we ensure the payload size is returned correctly, guiding
prepare_payload to the expected code section[1]

Tested on Catalina with continuous Redfish aggregation queries; no
errors or incorrect responses were observed.

[1] https://github.com/boostorg/beast/blob/fee9be0be10c9c9a22ac1505a710d1d8ed5a3dfb/include/boost/beast/http/impl/message.hpp#L364-L374

Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Signed-off-by: Ed Tanous <etanous@nvidia.com>
Change-Id: I4d84c8b6b9b3d65ce97e010b875ea49b3e1fc9d0

show more ...


# f51d8635 16-May-2024 Ed Tanous <ed@tanous.net>

Break out DuplicatableFileHandle

Static analysis notes that writing non-trivial move constructors and
move operator= handlers is non trivial [1]. Funnily enough, we actually
already had bugs on thi

Break out DuplicatableFileHandle

Static analysis notes that writing non-trivial move constructors and
move operator= handlers is non trivial [1]. Funnily enough, we actually
already had bugs on this that were fixed in 06fc9be.

Simplify the code.

Tested: Redfish service validator passes.

[1] https://sonarcloud.io/project/issues?issues=AY9_HYiwKXKyw1ZFwgUG%2CAY9_HYiwKXKyw1ZFwgUF&id=edtanous_bmcweb&open=AY9_HYiwKXKyw1ZFwgUG

Change-Id: If96383d8c669ae9e5a8cc13304071b2dfe1ff2d2
Signed-off-by: Ed Tanous <ed@tanous.net>

show more ...


# 0242baff 16-May-2024 Ed Tanous <ed@tanous.net>

Implement Chunking for unix sockets

Response::openFd was added recently to allow handlers to pass in a file
descriptor to be used to read. This worked great for files, but had
some trouble with uni

Implement Chunking for unix sockets

Response::openFd was added recently to allow handlers to pass in a file
descriptor to be used to read. This worked great for files, but had
some trouble with unix sockets. First, unix sockets have no known
length that we can get. They are fed by another client until that
client decides to stop sending data and sends an EOF. HTTP in general
needs to set the Content-Length header before starting a reply, so the
previous code just passes an error back.

HTTP has a concept of HTTP chunking, where a payload might not have a
known size, but can still be downloaded in chunks. Beast has handling
for this that we can enable that just deals with this at the protocol
layer silently. This patch enables that.

In addition, a unix socket very likely might not have data and will
block on the read call. Blocking in an async reactor is bad, and
especially bad when you don't know how large a payload is to be
expected, so it's possible those bytes will never come. This commit
sets all FDs into O_NONBLOCK[1] mode when they're sent to a response,
then handles the subsequent EWOULDBLOCK and EAGAIN messages when beast
propagates them to the http connection class. When these messages are
received, the doWrite loop is simply re-executed directly, attempting to
read from the socket again. For "slow" unix sockets, this very likely
results in some wasted cycles where we read 0 bytes from the socket, so
shouldn't be used for eventing purposes, given that bmcweb is
essentially in a spin loop while waiting for data, but given that this
is generally used for handling chunking of large payloads being
generated, and while spinning, other reactor operations can still
progress, this seems like a reasonable compromise.

[1] https://www.gnu.org/software/libc/manual/html_node/Open_002dtime-Flags.html

Tested:
The next patch in this series includes an example of explicitly adding a
unix socket as a response target, using the CredentialsPipe that bmcweb
already has. When this handler is present, curl shows the response
data, including the newlines (when dumped to a file)

```
curl -vvvv -k --user "root:0penBmc" https://192.168.7.2/testpipe -o output.txt
```

Loading the webui works as expected, logging in produces the overview
page as expected, and network console shows no failed requests.

Redfish service validator passes.

Change-Id: I8bd8586ae138f5b55033b78df95c798aa1d014db
Signed-off-by: Ed Tanous <ed@tanous.net>

show more ...


# e428b440 29-Mar-2024 Ed Tanous <ed@tanous.net>

Increase the file buffer

When we added file buffer, this number was picked arbitrarily. Prior to
the file body patch series, files were buffered entirely in ram,
regardless of what size they were.

Increase the file buffer

When we added file buffer, this number was picked arbitrarily. Prior to
the file body patch series, files were buffered entirely in ram,
regardless of what size they were. While not doing that was an
improvement, I suspect that we were overly conservative in the buffer
size.

Nginx picks a default buffer size somewhere in the 8k - 64k range
dependent on what paths the code takes. Using the higher end of
that range seems like a better starting point, but generally we
have more ram on the bmc than we have users.

Increase the buffer to 64K.

Tested: Unit tests pass.

[1] https://docs.nginx.com/nginx-management-suite/acm/how-to/policies/http-backend-configuration/#buffers

Change-Id: Idb472ccae02a8519c0976aab07b45562e327ce9b
Signed-off-by: Ed Tanous <ed@tanous.net>

show more ...


# 88c7c427 06-Apr-2024 Ed Tanous <ed@tanous.net>

Use fadvise to trigger sequential reading

Nginx and other webservers use fadvise to inform the kernel of
in-order reading. We should to the same.

Tested:
Webui loads correctly, no direct performan

Use fadvise to trigger sequential reading

Nginx and other webservers use fadvise to inform the kernel of
in-order reading. We should to the same.

Tested:
Webui loads correctly, no direct performance benefits immediately
obvious, but likely would operate better under load.

Change-Id: I4acce316c719df7df012cea8cb89237b28932c15
Signed-off-by: Ed Tanous <ed@tanous.net>

show more ...


# 06fc9beb 27-Mar-2024 Ed Tanous <ed@tanous.net>

Fix regression in http_file_body

The commit:
b5f288d Make use of filebody for dump offload

Caused a minor failure in clearing responses, where open file handles
wouldn't be closed in between querie

Fix regression in http_file_body

The commit:
b5f288d Make use of filebody for dump offload

Caused a minor failure in clearing responses, where open file handles
wouldn't be closed in between queries, resulting in the next read to
return empty content. This caused redfish protocol validator to fail.

boost::beast::http::response::clear() documentation shows that it only
clears the headers, not the file body. Now normally, this doesn't
matter, because bmcweb completely replaces the response body when a new
response is driven, but not in the case of files.

Add response.body().clear() during the clear to ensure the response is
cleared.

In addition, add encodingType to the clear() call, to ensure that it is
reset as well. This is a bug, but I don't know the reproduction steps.

Tested: Redfish protocol validator now completes (with SSE failures)

Change-Id: Ice6d5085003034a1bed48397ddc6316e9cd0536f
Signed-off-by: Ed Tanous <ed@tanous.net>

show more ...


# 0501696e 19-Mar-2024 Ed Tanous <ed@tanous.net>

Add nolint for naming violations

Change-Id: I0133bbd0a7573bd3d1e3c3c99382442b286696f6
Signed-off-by: Ed Tanous <ed@tanous.net>


# b2896149 31-Jan-2024 Ed Tanous <ed@tanous.net>

Rename FileBody to HttpBody

Now that our custom body type does things more than files, it makes
sense to rename it. This commit renames the header itself, then all
instances of the class.

Tested:

Rename FileBody to HttpBody

Now that our custom body type does things more than files, it makes
sense to rename it. This commit renames the header itself, then all
instances of the class.

Tested: Basic GET requests succeed.
Change-Id: If4361ac8992fc7c268f48a336707f96e68d3576c
Signed-off-by: Ed Tanous <ed@tanous.net>

show more ...