History log of /openbmc/bmcweb/http/http_response.hpp (Results 1 – 25 of 41)
Revision Date Author Comments
# d51c61b4 13-Sep-2024 Myung Bae <myungbae@us.ibm.com>

Fix status for non-existent JsonSchema FileGet

This will fix the incorrect status 500 to status 404 for the
non-eixstent JsonSchema FileGet.

```
% redfishtool raw GET -r ${bmc} -u root -p 0penBmc

Fix status for non-existent JsonSchema FileGet

This will fix the incorrect status 500 to status 404 for the
non-eixstent JsonSchema FileGet.

```
% redfishtool raw GET -r ${bmc} -u root -p 0penBmc -S Always /redfish/v1/JsonSchemas/ComputerSystem/ComputerSystem.v1_99_1.json
redfishtool: Transport: Response Error: status_code: 500 -- Internal Server Error
redfishtool: raw: Error getting response
```

This commit also refactor `Response::openFile()` to return `ec` so that
the caller can check the reason of the failure.

Tested:
- Verify redfishtool result for the non-existent JsonSchema file like
```
% redfishtool raw GET -r ${bmc} -u root -p 0penBmc -S Always /redfish/v1/JsonSchemas/<schema>/<non-existent-schema>.json
redfishtool: Transport: Response Error: status_code: 404 -- Not Found
redfishtool: raw: Error getting response
```
- Redfish Service validator passes

Change-Id: I98927c076bb6e7dfb3742183b4b3545e328d2657
Signed-off-by: Myung Bae <myungbae@us.ibm.com>

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 ...


# 499b5b4d 06-Apr-2024 Ed Tanous <ed@tanous.net>

Add static webpack etag support

Webpack (which is what vue uses to compress its HTML) is capable of
generating hashes of files when it produces the dist files[1].

This gets generated in the form of

Add static webpack etag support

Webpack (which is what vue uses to compress its HTML) is capable of
generating hashes of files when it produces the dist files[1].

This gets generated in the form of
<filename>.<hash>.<extension>

This commit attempts to detect these patterns, and enable etag caching
to speed up webui load times. It detects these patterns, grabs the hash
for the file, and returns it in the Etag header[2].

The behavior is implemented such that:
If the file has an etag, the etag header is returned.
If the request has an If-None-Match header, and that header matches,
only 304 is returned.

Tested:
Tests were run on qemu S7106 bmcweb with default error logging level,
and HTTP/2 enabled, along with svg optimization patches.

Run scripts/generate_auth_certificate.py to set up TLS certificates.
(valid TLS certs are required for HTTP caching to work properly in some
browsers).
Load the webui. Note that DOM load takes 1.10 seconds, Load takes 1.10
seconds, and all requests return 200 OK.
Refresh the GUI.
Note that most resources now return 304, and DOM time is reduced to
279 milliseconds and load is reduced to 280 milliseconds. DOM load
(which is what the BMC has control over) is decreased by a factor of
3-4X.
Setting chrome to "Fast 5g" throttling in the network tab shows a more
pronounced difference, 1.28S load time vs 3.96S.

BMC also shows 477KB transferred on the wire, versus 2.3KB
transferred on the wire. This has the potential to significantly
reduce the load on the BMC when the webui refreshes.

[1] https://webpack.js.org/guides/caching/
[2] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

Change-Id: I68aa7ef75533506d98e8fce10bb04a494dc49669
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 ...


# 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 ...


# 490d74d6 24-Feb-2024 Myung Bae <myungbae@us.ibm.com>

Fix duplicated etag generation

bmcweb generates the duplicated etags on GET and it may cause the
PATCH failure if etag is used - e.g. redfishtool..

This commit is to put only one Etag on http_respo

Fix duplicated etag generation

bmcweb generates the duplicated etags on GET and it may cause the
PATCH failure if etag is used - e.g. redfishtool..

This commit is to put only one Etag on http_response on GET.

Tested:

- Check the duplicated Etag on GET, and check it after fix

Before:
```
$ curl -v -k -X GET https://admin:${password}@${bmc}:18080/redfish/v1/AccountService/Accounts/readonly
...
< ETag: "D4B30BB4"
< ETag: "D4B30BB4"
```

After:
```
$ curl -v -k -X GET https://admin:${password}@${bmc}:18080/redfish/v1/AccountService/Accounts/readonly
...
< ETag: "D4B30BB4"
```

Change-Id: I5361919c5671b546181a26de792bc57de2c4f670
Signed-off-by: Myung Bae <myungbae@us.ibm.com>

show more ...


# 52e31629 23-Jan-2024 Ed Tanous <ed@tanous.net>

Simplify body

Now that we have a custom boost http body class, we can use it in more
cases. There's some significant overhead and code when switching to a
file body, namely removing all the headers

Simplify body

Now that we have a custom boost http body class, we can use it in more
cases. There's some significant overhead and code when switching to a
file body, namely removing all the headers. Making the body class
support strings would allow us to completely avoid that inefficiency.
At the same time, it would mean that we can now use that class for all
cases, including HttpClient, and http::Request. This leads to some code
reduction overall, and means we're reliant on fewer beast structures.

As an added benefit, we no longer have to take a dependency on
boost::variant2.

Tested: Redfish service validator passes, with the exception of
badNamespaceInclude, which is showing warnings prior to this commit.

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

show more ...


# b5f288d2 08-Nov-2023 Abhilash Raju <abhilash.kollam@gmail.com>

Make use of filebody for dump offload

Logservice has been rewritten to use file_body to offload dump files
from BMC.

There are two kind of dump files, BMC dump and System dump.While BMC
dump just r

Make use of filebody for dump offload

Logservice has been rewritten to use file_body to offload dump files
from BMC.

There are two kind of dump files, BMC dump and System dump.While BMC
dump just requires default support from beast::file_body, System dump
requires base64 encoding support from beast. But beast::file_body do not
have ready-made support for base64 encoding. So a custom file_body has
been written for the base64 encoding.

The openFile apis in crow::Response do not have support for unix file
descriptor. Since dump files are accesses via descriptors, added new
openFile api that accepts descriptors.

Tested:
Functionality test have been executed to verify the bmc dump offload.
Did sanity test by invoking bmcweb pages via browser.

Change-Id: I24192657c03d8b2f0394d31e7424c6796ba3227a
Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>

show more ...


# 8e3f7032 17-Jul-2023 Abhilash Raju <abhilash.kollam@gmail.com>

Reponse: Fix incomplete implementation in write

Write function in http_response.hpp missing implementation for first
write after changing from filebody.
Usecase:
Current resonse type is filebody. De

Reponse: Fix incomplete implementation in write

Write function in http_response.hpp missing implementation for first
write after changing from filebody.
Usecase:
Current resonse type is filebody. Developer tries to change the body
type to stringbody by calling write function.
Observed:
The write fails to update the body type.
Expected:
Write should succeed and body should change to string body.

Tested:
Unit test has been added for crow::Response.
Manual sanity test done for file offloads using curl.

Change-Id: Icbf8585b5b04c3ac5120d7b334c13d89ed3eb4aa
Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>

show more ...


# 27b0cf90 07-Aug-2023 Ed Tanous <ed@tanous.net>

Move to file_body in boost

As is, it reads the whole file into memory before sending it. While
fairly fast for the user, this wastes ram, and makes bmcweb less useful
on less capable systems.

This

Move to file_body in boost

As is, it reads the whole file into memory before sending it. While
fairly fast for the user, this wastes ram, and makes bmcweb less useful
on less capable systems.

This patch enables using the boost::beast::http::file_body type, which
has more efficient serialization semantics than using a std::string. To
do this, it adds a openFile() handler to http::Response, which can be
used to properly open a file. Once the file is opened, the existing
string body is ignored, and the file payload is sent instead.
openFile() also returns success or failure, to allow users to properly
handle 404s and other errors.

To prove that it works, I moved over every instance of direct use of the
body() method over to using this, including the webasset handler. The
webasset handler specifically should help with system load when doing an
initial page load of the webui.

Tested:
Redfish service validator passes.

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

show more ...


# e01d0c36 30-Jun-2023 Ed Tanous <edtanous@google.com>

Fix bugprone-unchecked-optional-access findings

Clang-tidy has the aforementioned check, which shows a few places in the
core where we ignored the required optional checks. Fix all uses.
Note, we c

Fix bugprone-unchecked-optional-access findings

Clang-tidy has the aforementioned check, which shows a few places in the
core where we ignored the required optional checks. Fix all uses.
Note, we cannot enable the check that this time because of some weird
code in health.hpp that crashes tidy[1]. That will need to be a future
improvement.

There are tests that call something like
ASSERT(optional)
EXPECT(optional->foo())

While this isn't an actual violation, clang-tidy doesn't seem to be
smart enough to deal with it, so add some explicit checks.

[1] https://github.com/llvm/llvm-project/issues/55530

Tested: Redfish service validator passes.

Change-Id: Ied579cd0b957efc81aff5d5d1091a740a7a2d7e3
Signed-off-by: Ed Tanous <edtanous@google.com>

show more ...


# 62598e31 17-Jul-2023 Ed Tanous <ed@tanous.net>

Replace logging with std::format

std::format is a much more modern logging solution, and gives us a lot
more flexibility, and better compile times when doing logging.

Unfortunately, given its level

Replace logging with std::format

std::format is a much more modern logging solution, and gives us a lot
more flexibility, and better compile times when doing logging.

Unfortunately, given its level of compile time checks, it needs to be a
method, instead of the stream style logging we had before. This
requires a pretty substantial change. Fortunately, this change can be
largely automated, via the script included in this commit under
scripts/replace_logs.py. This is to aid people in moving their
patchsets over to the new form in the short period where old patches
will be based on the old logging. The intention is that this script
eventually goes away.

The old style logging (stream based) looked like.

BMCWEB_LOG_DEBUG << "Foo " << foo;

The new equivalent of the above would be:
BMCWEB_LOG_DEBUG("Foo {}", foo);

In the course of doing this, this also cleans up several ignored linter
errors, including macro usage, and array to pointer deconstruction.

Note, This patchset does remove the timestamp from the log message. In
practice, this was duplicated between journald and bmcweb, and there's
no need for both to exist.

One design decision of note is the addition of logPtr. Because the
compiler can't disambiguate between const char* and const MyThing*, it's
necessary to add an explicit cast to void*. This is identical to how
fmt handled it.

Tested: compiled with logging meson_option enabled, and launched bmcweb

Saw the usual logging, similar to what was present before:
```
[Error include/webassets.hpp:60] Unable to find or open /usr/share/www/ static file hosting disabled
[Debug include/persistent_data.hpp:133] Restored Session Timeout: 1800
[Debug redfish-core/include/event_service_manager.hpp:671] Old eventService config not exist
[Info src/webserver_main.cpp:59] Starting webserver on port 18080
[Error redfish-core/include/event_service_manager.hpp:1301] inotify_add_watch failed for redfish log file.
[Info src/webserver_main.cpp:137] Start Hostname Monitor Service...
```
Signed-off-by: Ed Tanous <ed@tanous.net>

Change-Id: I86a46aa2454be7fe80df608cb7e5573ca4029ec8

show more ...


# 994fd86a 06-Jun-2023 Ed Tanous <edtanous@google.com>

Fix hack on Set-Cookie

This is one that I couldn't figure out for a while. Turns out that
fields has both a set() and an insert() method. Whereas set() replaces,
insert() appends, which is what we

Fix hack on Set-Cookie

This is one that I couldn't figure out for a while. Turns out that
fields has both a set() and an insert() method. Whereas set() replaces,
insert() appends, which is what we want in this case.

This allows us to call the actual methods several times, instead of
essentially string injecting our own code, which should make it clearer.

At the same time, there was one unit test that was structured such that
it was using addHeader to clear a header, so this commit adds an
explicit "clearHeader()" method, so we can be explicit.

Tested:
Logging into the webui in chrome (which uses POST /login) shows:
401 with no cookie header if the incorrect password is used
200 with 2 Set-Cookie headers set:
Set-Cookie:
SESSION=<session tag>; SameSite=Strict; Secure; HttpOnly
Set-Cookie:
XSRF-TOKEN=<token tag>; SameSite=Strict; Secure

Change-Id: I9b87a48ea6ba892fc08e66940563dea86edb9a65
Signed-off-by: Ed Tanous <edtanous@google.com>

show more ...


# 6fde95fa 01-Jun-2023 Ed Tanous <edtanous@google.com>

Server-sent-event fixes

This makes several changes to server-sent events to allow it to merge
to master. The routing system has been removed in leiu of using
content-type eventstream detection. Ti

Server-sent-event fixes

This makes several changes to server-sent events to allow it to merge
to master. The routing system has been removed in leiu of using
content-type eventstream detection. Timers have been added to the
sse connections, and sse connections now rely on async_wait, rather
than a full read.

Tested: WIP

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Id0ff0ebc2b3a795b3dba008e440556a9fdd882c2

show more ...


# 88ada3bc 13-Apr-2023 V-Sanjana <sanjana.v@intel.com>

Add Server-Sent-Event support

Server-Sent-Event is a standard describing how servers can initiate
data transmission towards clients once an initial client connection has
been established. Unlike web

Add Server-Sent-Event support

Server-Sent-Event is a standard describing how servers can initiate
data transmission towards clients once an initial client connection has
been established. Unlike websockets (which are bidirectional),
Server-Sent-Events(SSE) are unidirectional and commonly used to send
message updates or continuous data streams to a browser client.

This is base patch for adding Server-Sent-Events routing support to
bmcweb. Redfish EventService SSE style subscription uses SSE route for
sending the Events/MetricReports to client which establishes the
connection.

Tested this patch with along with EventService SSE support patches and
verified the functionalty on browser.

Tested:
- Tested using follow-up patches on top which adds
support for Redfish EventService SSE style subscription
and observed events are getting sent periodically.
- Created SSE subscription from the browser by visiting
https://<BMC IP>/redfish/v1/EventService/SSE

Change-Id: I36956565cbba30c2007852c9471f477f6d1736e9
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
Signed-off-by: P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com>
Signed-off-by: V-Sanjana <sanjana.v@intel.com>

show more ...


# faf100f9 25-May-2023 Ed Tanous <edtanous@google.com>

Fix some includes

System includes should be included with <>, in-tree includes should be
included with "". This was found manually, with the help of the
following grep statement[1].

git grep -o -h

Fix some includes

System includes should be included with <>, in-tree includes should be
included with "". This was found manually, with the help of the
following grep statement[1].

git grep -o -h "#include .*" | sort | uniq

Tested:
Code compiles

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I1a6b2a5ba35ccbbb61c67b7c4b036a2d7b3a36a3

show more ...


# a6695a84 16-May-2023 Ed Tanous <edtanous@google.com>

Clear json object

nlohmann::json::clear() has different behavior dependent on what the
underlying object is, rather than doing the expected behavior of
completely clearing the json object. This did

Clear json object

nlohmann::json::clear() has different behavior dependent on what the
underlying object is, rather than doing the expected behavior of
completely clearing the json object. This didn't matter because of a
similar bug in http_connection that relied on nlohmann:json::empty()
which is ALSO type dependent, so these worked.

Unfortunately, in 02e01b5108d46720a0b438c0d79952464320d954 we wanted to
allow empty objects, and this bug was exposed.

There are two places where clear() is used, once in Response, which is
clearly not the intent, which is to reset the object to the original
constructed state. The other place we call clear is in Manager, where
we use it to clear incremental results. That was a previous best practice that has been eliminated everywhere else (now we return as
many results with the error as we are able). It has been removed.

Tested: Logging into the webui in firefox no longer core dumps.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic89a037b30fb40c0e6eaeb939cae6e006dd0ffac

show more ...


# eea9c979 15-May-2023 Ed Tanous <edtanous@google.com>

Clean up preparePayload

boost::beast::http::message::prepare_payload [1] can throw, which isn't
really the behavior we want (as it throws to the io_context). Luckily,
every part of that function is

Clean up preparePayload

boost::beast::http::message::prepare_payload [1] can throw, which isn't
really the behavior we want (as it throws to the io_context). Luckily,
every part of that function is using public methods, and we can simplify
it.

In past commits, we've worked around this issue:
6295becabb9edba2edb53a3c0dddc13d2ffac8dd

This is an attempt to fix it properly.

[1] https://github.com/boostorg/beast/blob/ae01f0201dbf940cbc32d96d7a78dc584a02ab26/include/boost/beast/http/impl/message.hpp#L398

Redfish service validator passes

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ie88ddeecfd226bba75a7659cfb7ddddd38eb27cb

show more ...


# 89492a15 10-May-2023 Patrick Williams <patrick@stwcx.xyz>

clang-format: copy latest and re-format

clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest

clang-format: copy latest and re-format

clang-format-16 has some backwards incompatible changes that require
additional settings for best compatibility and re-running the formatter.
Copy the latest .clang-format from the docs repository and reformat the
repository.

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

show more ...


# 26ccae32 16-Feb-2023 Ed Tanous <edtanous@google.com>

Pass string views by value

string_view should always be passed by value; This commit is a sed
replace of the code to make all string_views pass by value, per general
coding guidelines[1].

[1] http

Pass string views by value

string_view should always be passed by value; This commit is a sed
replace of the code to make all string_views pass by value, per general
coding guidelines[1].

[1] https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/

Tested: Code compiles.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I55b342a29a0fbfce0a4ed9ea63db6014d03b134c

show more ...


# 3ccb3adb 13-Jan-2023 Ed Tanous <edtanous@google.com>

Fix a boatload of #includes

Most of these missing includes were found by running clang-tidy on all
files, including headers. The existing scripts just run clang-tidy on
source files, which doesn't

Fix a boatload of #includes

Most of these missing includes were found by running clang-tidy on all
files, including headers. The existing scripts just run clang-tidy on
source files, which doesn't catch most of these.

Tested: Code compiles

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic741fbb2cc9e5e92955fd5a1b778a482830e80e8

show more ...


# f8fe53e7 30-Jun-2022 Ed Tanous <edtanous@google.com>

Change variable scopes

cppcheck correctly notes that a lot of our variables can be declared at
more specific scopes, and in every case, it seems to be correct.

Tested: Redfish service validator pas

Change variable scopes

cppcheck correctly notes that a lot of our variables can be declared at
more specific scopes, and in every case, it seems to be correct.

Tested: Redfish service validator passes. Unit test coverage on others.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia4414410d0e8f74a3bd40fdc0e0232450d1a6416

show more ...


# 2d6cb56b 07-Jul-2022 Ed Tanous <edtanous@google.com>

Implement If-Match header in Http layer

If-Match is a header in the HTTP specification[1] designed for handling
atomic operations within a given HTTP tree. It allows a mechanism for
an implementati

Implement If-Match header in Http layer

If-Match is a header in the HTTP specification[1] designed for handling
atomic operations within a given HTTP tree. It allows a mechanism for
an implementation to explicitly declare "only take this action if the
resource has not been changed". While most things within the Redfish
tree don't require this level of interlocking, it continues to round out
our redfish support for the specific use cases that might require it.

Redfish specification 6.5 states:
If a service supports the return of the ETag header on a resource, the
service may respond with HTTP 428 status code if the If-Match or
If-None-Match header is missing from the PUT or PATCH request for the
same resource, as specified in RFC6585

This commit implements that behavior for all handlers to follow the
following flow.
If If-Match is present
Repeat the same request as a GET
Compare the ETag produced by the GET, to the one provided by If-Match
If they don't match, return 428
if they do match, re-run the query.

[1] https://www.rfc-editor.org/rfc/rfc2616#section-14.24

As a consequence, this requires declaring copy and move constructors
onto the Request object, so the request object can have its lifetime
extended through a request, which is very uncommon.

Tested:
Tests run on /redfish/v1/AccountService/Accounts/root
PATCH with correct If-Match returns 200 success
PATCH with an incorrect If-Match returns 419 precondition required
GET returns the resource as expected

Redfish service validator passes
Redfish protocol validator passes! ! ! ! !

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I530ab255259c32fe4402eb8e5104bd091925c77b

show more ...


# 291d709d 13-Apr-2022 Ed Tanous <edtanous@google.com>

Implement If-None-Match support for caching client

This commit implements support for the If-None-Match header on http
requests. This can be combined with the
89f180089bce9cc431d0b1053410f262f157b9

Implement If-None-Match support for caching client

This commit implements support for the If-None-Match header on http
requests. This can be combined with the
89f180089bce9cc431d0b1053410f262f157b987 commit for producing ETag to
allow a client to have a highly efficient cache, while still pulling
data from the BMC.

This behavior is documented several places, in W3C produced docs[1], as
well as section 7.1 of the Redfish specification:
'''
A service only returns the resource if the current ETag of that resource
does not match the ETag sent in this header.
If the ETag in this header matches the resource's current ETag, the GET
operation returns the HTTP 304 status code.
'''

Inside bmcweb, this behavior is accomplished in a relatively naive way,
by creating the complete request, then doing a direct ETag comparison
between the generated data and the request header. In the event the two
match, 304 not-modified is returned, in-line with both the Redfish
specification and the HTTP RFC.

[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match

Tested (on previous rebase):
First, request ServiceRoot
curl --insecure -vvvv --user root:0penBmc https://192.168.7.2/redfish/v1

This returns a header similar to:
< ETag: "ECE52663"

Taking that ETag, and putting it into an If-None-Match header:
```
curl --insecure -vvvv -H "If-None-Match: \"ECE52663\"" \
--user root:0penBmc https://192.168.7.2/redfish/v1
```

Returns:
< HTTP/1.1 304 Not Modified
...
< Content-Length: 0

Showing that the payload was not repeated, and the response size was
much.... much smaller on the wire. Performance was not measured as part
of this testing, but even if it has no performance impact (which is
unlikely), this change is still worthwhile to implement more of the
Redfish specification.

Redfish-service-validator passes.
Redfish-protocol-validator passes 1 more atom in comparison to previous.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I1e7d41738884593bf333e4b9b53d318838808008

show more ...


# 3590bd1d 12-Aug-2022 Nan Zhou <nanzhoumails@gmail.com>

query: propogate errors for expand

The existing code doesn't propogate errors of subqueries correctly.
This commit corrects the behavior, so that the final response gets all
error message of subquer

query: propogate errors for expand

The existing code doesn't propogate errors of subqueries correctly.
This commit corrects the behavior, so that the final response gets all
error message of subqueries and the "highest priority" HTTP code.

DMTF doesn't specify how expand queries handle error codes, since using
subqueries is an implementation choice that we made in this project.

What we did here follows existing behavior of this project, and follows
the error message section of the Redfish spec;
[1] https://redfish.dmtf.org/schemas/DSP0266_1.15.1.html#error-responses

As for now, this commit uses the worst HTTP code among all the error
code. See query_param.hpp, function |propogateErrorCode| for detailed
order of the errror codes.

Tested:
1. this is difficult to test, but I hijacked the code so it returns
errors in TaskServices, then I verified that "/redfish/v1?$expand=."
correctly returns 500 and the gets the error message set.
2. unit test so that when there are multiple errors, the final response
gets a generate error message.

Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I0c1ebdd9015f389801db9150d687027485f1203c

show more ...


12