summaryrefslogtreecommitdiff
path: root/http
AgeCommit message (Collapse)AuthorFilesLines
2022-04-29Delete forked function_traitsEd Tanous2-46/+8
The function_traits class was very clearly "borrowed" from boost::function traits, then added to to support lambdas. boost::function_traits has been superceeded by boost::callable_traits, which fixes the same shortcomings that we have fixed here. This commit replaces almost the entirety of the uses of function_traits with callable traits, with one exception: arg<i>. In the callable traits model, arg_t is a std::tuple, which, while better, doesn't unpack easily into a variadic pack that our router code expects. Ideally, at some point, we would rewrite the router core to not rely on std::make_integer_sequence, but that's a much more invasive change. Tested: Called curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Managers/bmc/LogServices/Journal/Entries/1646953359619803 and verified callback return the correct result (not 404). That API has several flexible router parameters, which is the only thing this commit could break. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Icf3299b2d5c1a5ff111f68858bb46139735aaabe
2022-04-19Remove regex uses in event service and consolidateEd Tanous3-43/+91
As the patch at https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/50994 can attest, parsing urls with a regex is error prone. We should avoid it where possible, and we have boost::urls that implements a full, correct, and unit tested parser. Ideally, eventually this helper function would devolve into just the parse_uri, and setting defaults portion, and we could rely on the boost::urls::url class to pass into things like http_client. As a side note, because boost url implements port as a proper type-safe uint16, some interfaces that previously accepted port by std::string& needed to be modified, and is included in this patch. Also, once moved, the branch on the ifdef for HTTP push support was failing a clang-tidy validation. This is a known limitation of using ifdefs for our code, and something we've solved with the header file, so move the http push enabler to the header file. Also note that given this reorganization, two EXPECT statements are added to the unit tests for user input behaviors that the old code previously did not handle properly. Tested: Unit tests passing Ran Redfish-Event-Listener, saw subscription create properly: Subcription is successful for https://192.168.7.2, /redfish/v1/EventService/Subscriptions/2197426973 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia4127c6cbcde6002fe8a50348792024d1d615e8f
2022-04-13Add common url segments parserSzymon Dompke2-2/+121
This change is adding helper template function, which can be used both to validate and read segments from segments_view returned by boost_url parser. Number of segments is also validated - in case when argument count differs from them, false will be returned. In case when we want to validate only existence of a segment, special argument can be passed in its place: 'anySegment'. Reasoning why url_view was chosen instead of strings: - This way code generation is kept minimal. - There are multiple parse functions in boost_url with different rules, but all of them return url_view. This solution should accommodate every use case. Testing done: - Unit tests are added, passing. - Refactored part of telemetry to use this new approach, no regression spotted during simple POST/GET tests. Change-Id: I677a34e1ee570d33f2322a80dc1629f88273e0d5 Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
2022-04-05Redfish: Query parameters: OnlyEd Tanous1-1/+0
Add the query parameter "only" for redfish. The specification is based on DSP0266_1.8.0. This commit is inspired by the commit that carries the same title, but is largely unique, namely, in that it adds the core feature to be able to recall handle with a new Response object, and make sure the result gets to the connection. It does this by swapping the handlers and implementing move semantics on the Response object. It definitely needs broken up into a few smaller patches, but it does pass the below tests without any apparent seg faults or ownership issues. It implements a number of cleanups that deserve their own patches, and will be split up accordingly, but for the moment, I think this is a good start to getting filter and expand support in the future. Tested: Validator passes (on previous patchset) ~$ curl -i -k -H "X-Auth-Token: $token" -X GET "https://${bmc}/redfish/v1/Systems" ~$ curl -i -k -H "X-Auth-Token: $token" -X GET "https://${bmc}/redfish/v1/Systems?only" Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I123d8ab8bcd88a0b63ff131f6b98548951989755
2022-03-29Remove AsyncResp from openHandlerzhanghch052-11/+4
This change, moving the openHandler back to only supporting websocket disconnects and not 404s.Because AsyncResp is removed from openHandler. Tested: (from previous commit) Opened KVM in webui-vue and it works. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I793f05836aeccdc275b7aaaeede41b3a2c276595
2022-03-28Drop unused App.sslFile() methodJiaqing Zhao1-41/+0
App.sslFile() method is never called, the sslContext is generated in ensuressl::getSslContext() function now. So remove these unused code. Tested: Build pass. Change-Id: I2737462a3a2ec2e0dc792e5070e9e5a7244bc889 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
2022-03-22Refactor getParameterTagEd Tanous1-85/+86
The aforementioned method is recursive, which prevents us from enabling recursive checks. This is from back in the days when constexpr string_view didn't exist, and recursion was the only way to do string parsing. These days, we are much more evolved, so simplify the method. Tested: Code compiles (this is a constexpr method) and unit tests pass Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3b8364ac38a14faf546edb85deae7071f7558f4b
2022-03-22Consitently use dbus::utility typesEd Tanous1-39/+37
This saves about 4k on the binary size Tested: Redfish service validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9546227a19c691b1aecb80e80307889548c0293f
2022-03-17Remove special router logic for trailing slashEd Tanous1-51/+2
The trailing slash logic in the router has been long since deprecated in leiu of adding two routes internally, so this "special case" is no longer needed or used, as can be seen from the variable being read, but never set anywhere. Tested: curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/SessionService/Sessions/ Succeeds Ran redfish service validator. No new failures. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9a6744d311aacaed1cc3eb3a98d55006c5b4246d
2022-03-10Remove unused utility classesEd Tanous1-30/+0
These are no longer used. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id712a413c4c84f80b9e352c916032537308fc8c3
2022-03-10Add back getParameterTag unit testsEd Tanous1-0/+19
These unit tests existed a long time ago and were shut off a while back. Might as well enable them before we do some cleanup. Tested: Unit tests pass Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8211b8c3f53b979bfde27691a89a52c058718e67
2022-03-07Don't rely on operator << for object loggingEd Tanous3-6/+8
In the upcoming fmt patch, we remove the use of streams, and a number of our logging statements are relying on them. This commit changes them to no longer rely on operator>> or operator+ to build their strings. This alone isn't very useful, but in the context of the next patch makes the automation able to do a complete conversion of all log statements automatically. Tested: enabled logging on local and saw log statements print to console Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I0e5dc2cf015c6924037e38d547535eda8175a6a1
2022-03-04Fix the build for time_tEd Tanous1-5/+7
Current code doesn't build because of an error injected into a patch (ironically attempting to fix the build). Tested: Code compiles within yocto 32 bit, and out of yocto 64 bit. unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ibc4ea4617853bf717c10d812eb5d8a9352177f24
2022-03-02Fix constexpr on clangEd Tanous1-2/+5
clang correctly notes that this branch is impossible to hit on 32 bit systems, so wrap it in an if contexpr check to check for 32 bit, and avoid the next branch entirely. Tested: code compiles further on clang. Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iccaab8402d839faa7c3f7cea457ef6bcba832f67
2022-03-01Change the completionhandler to accept ResNan Zhou3-34/+60
These modifications are from WIP:Redfish:Query parameters:Only (https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/47474). It will be used in future CLs for Query Parameters. The code changed the completion handle to accept Res to be able to recall handle with a new Response object. AsyncResp owns a new res, so there is no need to pass in a res. Also fixed a self-move assignment bug. Context: Originally submitted: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/480020 Reveted here: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/48880 Because of failures here: https://gerrit.openbmc-project.xyz/c/openbmc/openbmc/+/48864 Tested: 1. Romulus QEMU + Robot tests; all passed 2. Use scripts/websocket_test.py to test websockets. It is still work correctly. 3. Tested in real hardware; no new validator errors; tested both authless, session, and basic auth. 4. Hacked codes to return 500 errors on certain resource; response is expected; 5. Tested Eventing, the push style one (not SSE which is still under review), worked as expected. 6. Tested 404 errors; response is expected. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Signed-off-by: John Edward Broadbent <jebr@google.com> Change-Id: I52adb174476e0f6656335baa6657456752a031be
2022-03-01Make the router const correctEd Tanous1-9/+12
Subtly, the individual members of a const std::pair are not implicitly const. In most cases, this is solved by a compiler error, but it seems that flat_map allows implicitly pulling out by a non const reference, even when the underlying container is const. This is not how the maps should work. This commit changes the router to declare a "ChildMap" type, which can then use the value_type to make this const correctness stuff more reasonable to manage. Tested: Code compiles. No-op const change. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id99079a86e392a03416a69506934dbfff7bc3b29
2022-02-28websocket: fix authlessNan Zhou2-1/+4
We should check if session is nullptr before referencing its data member. Tested: 1. build authless BMCWeb ``` meson -Drest=enabled -Dbmcweb-logging=enabled -Dinsecure-disable-auth=enabled build && ninja -C build && ./build/bmcweb ``` 2. start websocket client without problems ``` python scripts/websocket_test.py --host localhost:18080 ``` 3. bmcweb log ``` [DEBUG "websocket.hpp":221] Websocket accepted connection [DEBUG "dbus_monitor.hpp":114] Connection opened [DEBUG "dbus_monitor.hpp":115] Connection 0x55b22d618670 opened [DEBUG "http_response.hpp":134] 0x55b22d611040 calling completion handler [DEBUG "dbus_monitor.hpp":129] Connection 0x55b22d618670 received {"paths": ["/xyz/openbmc_project/sensors"], "interfaces": ["xyz.openbmc_project.Sensor.Value"]} [DEBUG "dbus_monitor.hpp":231] Creating match type='signal',interface='org.freedesktop.DBus.Properties', path_namespace='/xyz/openbmc_project/sensors',member='PropertiesChanged', arg0='xyz.openbmc_project.Sensor.Value' [DEBUG "dbus_monitor.hpp":246] Creating match type='signal',interface='org.freedesktop.DBus.ObjectManager', path_namespace='/xyz/openbmc_project/sensors',member='InterfacesAdded' ``` Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I56613a26c129736f0e6980bb24e83f22ef60eea0
2022-02-28Add url type safety to message registryEd Tanous1-2/+3
There are a number of places where we use message registry messages incorrectly. This patchset attempts to fix them, and invoke some type safety when they're used such that they're more obvious to use. Namely, it changes a number of the message registry methods to accept a boost::urls::url_view for its argument instead of a const std::string&. This forces the calling code to correctly encode a URL to use the method, which should make it obvious that it's not for an ID, a property name, or anything else. In the course of doing this, several places were found to be using the first argument incorrectly. Tested: curl --insecure --user root:0penBmc https://192.168.7.2/redfish/v1/Chassis/foobar Returns: { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type #Chassis.v1_16_0.Chassis named foobar was not found.", "MessageArgs": [ "#Chassis.v1_16_0.Chassis", "foobar" ], "MessageId": "Base.1.8.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.8.1.ResourceNotFound", "message": "The requested resource of type #Chassis.v1_16_0.Chassis named foobar was not found." } Identically to previously. Also tested with IDs that contained % encoded characters, like foobar%10, which gave the same result. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Icbb3bce5d190a260610087c9ef35e7becc5a50c7
2022-02-25json_utils: Add support jsonRead Patch/ActionWilly Tu1-1/+1
Added support for readJson for Patch and Action. The only difference is that Patch does not allow empty json input while Action does. Action with empty input will use the default value based on the implementation and return 200 OK response code. readJsonPatch will replace the existing readJson and be used for path requests. It will not allow empty json input and all requested keys are required in the json input. readJsonAction will be used for Action requests where it is possible for all of the properties to be optional and allow empty request. The optional properties are determined by the requested values type. All current Action readJson are replaced with readJsonAction. It does not change the existing behavior since it needs `std::optional`. This will have to be updated later as we define the default behavior. Tested: Added unit tests and readJsonAction allows empty empty json object. No Change to Redfish Tree. Change-Id: Ia5e1f81695c528a20f1dc985aee19c920d8adaea Signed-off-by: Willy Tu <wltu@google.com>
2022-02-15Move validateAndSplitUri to common utility headerEd Tanous2-0/+87
This function in practice looks like it has another use where the code is essentially the same. Move it to a header so it can be used by other things. And add unit tests to ensure it stays reliable. Tested: Unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3343ba1aa9c0dd542fbb98628b7628cb0704fb3b
2022-02-15Enable readability-uppercase-literal-suffixEd Tanous1-1/+1
We only had a few violations of this; Fix them and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I159e774fd0169a91a092218ec8dc896ba9edebf4
2022-02-15Enable readability-implicit-bool-conversion checksEd Tanous1-17/+18
These checks ensure that we're not implicitly converting ints or pointers into bools, which makes the code easier to read. Tested: Ran series through redfish service validator. No changes observed. UUID failing in Qemu both before and after. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I1ca0be980d136bd4e5474341f4fd62f2f6bbdbae
2022-02-11Add readability-redundant-* checksEd Tanous3-4/+3
There's a number of redundancies in our code that clang can sanitize out. Fix the existing problems, and enable the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie63d7b7f0777b702fbf1b23a24e1bed7b4f5183b
2022-02-09Enable readability-avoid-const-params-in-declsEd Tanous4-6/+7
This check involves explicitly declaring variables const when they're declared auto, which helps in readability, and makes it more clear that the variables are const. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I71198ea03850384a389a56ad26f2c4a48c75b148
2022-02-08Add UrlFromPieces helper functionEd Tanous2-0/+37
This commit attempts to improve our ability to encode URIs from pieces of a string. In the past, we've used std::string::operator+= for this, which has problems in that bad characters are not encoded correctly into a URI. As an example, if we got a dbus path with _2F (ascii /) in it, our current code would push that directly into the uri and break the redfish tree. Examples of use are provided in the unit tests. Tested: Unit tests pass, no functional changes yet. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5801d2146a5c948396d4766ac96f1f2b25205a0f
2022-02-07Enable readability-redundant-control-flow checksEd Tanous1-3/+0
These checks are a nice addition to our static analysis, as they simplify code quite a bit, as can be seen by this diff being negative lines. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I60ede4ad23d7e5337e811d70ddcab24bf8986891
2022-02-07Enable readability-named-parameter checksEd Tanous1-20/+23
We don't have too many violations here, probably because we don't have many optional parameters. Fix the existing instances, and enable the check. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I4d512f0ec90b060fb60a42fe3cd6ba72fb6c6bcb
2022-02-04Remove NEW_BOOST_URL macroEd Tanous1-20/+1
Now that the subtree update is done, this define is no longer needed. Tested: Code compiles. Noop. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Idc5d7ef69c009982a2476fadc1d95e3280bfff48
2022-02-04Remove getTimestampEd Tanous1-10/+0
The aforementioned function is only used in the log services, and is used incorrectly in that context. This commit replaces it with the correct (and unit tested) getDateTimeUintMs, which is what we should be using for dbus->time conversions in all cases, to avoid time_t overflows when static casting. Tested: Before "Created": "2022-01-31T19:39:58+00:00", "Modified": "2022-01-31T19:39:58+00:00", With change: "Created": "2022-01-31T19:39:58.101000+00:00", "Modified": "2022-01-31T19:39:58.101000+00:00", The Redfish validator is okay with this *** /redfish/v1/Systems/system/LogServices/EventLog/Entries/1000 Type (LogEntry.v1_8_0.LogEntry), GET SUCCESS (time: 0) PASS Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie8a2243230ee080d9e8785ae918fad1b1b6ab145
2022-02-02Next round of boost-uri updatesEd Tanous1-0/+19
Boost url has changed some APIs again. This commit updates our URIs to handle it. As part of this work, it also removes some of the debug prints that were put in early on. These aren't really needed these days. This commit invents a temporary #define of NEW_BOOST_URL, so we can get through the subtree update without a hard dependency on this specific version of bmcweb. Ideally boost-url would have some version field, but unfortunately, it is thusfar unversioned, as the long term intent of the author is to be included in boost, and would be versioned there. All the code within the else of the NEW_BOOST_URL flag will be removed once the subtree update is landed. Tested: Added CXXFLAGS:append = " -DNEW_BOOST_URL" to the recipe and checked out on top of the subtree update, and build succeeded. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie2064e45efbc4331bdc5a5ddf44d877cde5e13cb
2022-01-28Enable readability-container-size-empty testsEd Tanous1-1/+1
This one is a little trivial, but it does help in readability. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5366d4eec8af2f781b3bad804131ae2eb806e3aa
2022-01-27getDateTimeStdtime: fix building warnings in 32bitsNan Zhou1-7/+12
Also made std::min their own lines to be more readable. Tested: unit test passes and it builds via bitbake. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ic32b886cca7c2901d77b4baffd4d4a6d655e0b14
2022-01-25Fix Boost exceptions in GetDateTime seriesEd Tanous2-32/+45
In cases when the input time is too large, we return the maximum supported date in the ISO Extended format. Tested: Unit tests pass Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I0dcd60d10d4357bd8700f0dbc1ef86d94bcc82bb
2022-01-25Update unit tests for getDateTimeEd Tanous1-7/+40
the GetDateTime series needs more unit tests to ensure that we don't get bad behavior when we hit the extremes. This commit does include one tests, for getDateTimeUint that currently throws an exception that shouldn't, which is currently commented out. This needs looked at by someone. Tested: Unit tests pass Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7f45e5d84d644780832112dca14bdb9c768903ff
2022-01-19Include what you useEd Tanous1-3/+6
Do a partial update from the include what you use tool. While ideally we'd be able to do this as part of CI, there's still quite a bit of noise in the output that requires manual intervention. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iaaeb7a9199f64b5d6913c3abab4779b252768ed8
2022-01-12Enable pro-type-cstyle-cast checksEd Tanous1-2/+3
We actually do a pretty good job of this, and only have one C style cast, that's part of an openssl macro, so ignore the one, and enable the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie0462ee947c8310457365ba2aeea78caedb93da1
2022-01-12Enable pointer devolution checksEd Tanous1-0/+4
Enable cpp core guidelines checks for pointer deevolution. For the moment, simply ignore the uses, although ideally these should be cleaned up at some point. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I9a8aae94cc7a59529eab89225a37e89628c17597
2022-01-12Enable cpp core guidelines macro checksEd Tanous2-0/+14
We only use a couple macros. Ignore them in the checks. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I38feb10f76f6aaea8899617f081c9be68c88b3eb
2022-01-12Enable checks for pointer arithmeticEd Tanous1-2/+4
Quite a few places we've disobeyed this rule, so simply ignore them for now to avoid new issues popping up. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3e518a8e8742279afb3ad1a9dad54006ed109fb1
2022-01-12Enable reinterpre_cast checksEd Tanous1-2/+4
We seem to use reinterpret cast in a few cases unfortunately. For the moment, simply ignore most of them, and make it so we don't get more. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ic860cf922576b18cdc8d51d6132f5a9cbcc1d9dc
2022-01-12Enable cppcoreguidelines-special-member-functions checksEd Tanous7-0/+32
Part of enforcing cpp core guidelines involves explicitly including all constructors required on a non-trivial class. We were missing quite a few. In all cases, the copy/move/and operator= methods are simply deleted. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ie8d6e8bf2bc311fa21a9ae48b0d61ee5c1940999
2022-01-12Enable init checkerEd Tanous2-7/+7
clang-tidy added cppcoreguidelines-init-variables as a check, which is something we already enforce to some extent, but getting CI to enforce it will help reviews move faster. Tested: Code compiles. Noop changes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7e10950de617b1d3262265572b1703f2e60b69d0
2022-01-12Enable bugprone widening checks in clangEd Tanous1-2/+2
Most of the errors we hit are simply places we need to explicitly increase the width of the integer. Luckily, these are few and far between. Tested: Code compiles, unit tests pass. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I617d87f3970ae773e0767bb2f20118fca2e71daa
2022-01-12Enable clang-tidy forward reference checksEd Tanous2-6/+7
Clang-13 adds new checks we can turn on, which find quite a few errors. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I74b780760014c898cc440b37aea640b33e91c439
2022-01-11Fixed timestamp in telemetry serviceKrzysztof Grobelny1-11/+17
Telemetry service is using timestamp with milliseconds accuracy. Bmcweb code assumed that timestamp is in seconds which produced a bad result. This patchset updates the APIs, and adds a getDateTimeUintMs method, which can be used to convert a millisecond timestamp into a string. In the future, this can be used to get more precision out of the API. Reference: '9.4.3. Date-Time values' https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.8.0.pdf Tested: - Telemetry service timestamp show correct timestamp with milliseconds precission. Example: 2022-01-11T13:06:58.648000+00:00 - Other timestamps in bmcweb did not change - All unit tests are passing Reference: Properties.Readings https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Telemetry/Report.interface.yaml Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I5b40ef6889b5af8c045ec0d35a758967e53dbed2
2021-12-29http_connection: Fix loggedIn check and timeoutLei YU1-1/+1
The code was using `req && req->session` to check if the session is logged in. It is not working anymore and should use `userSession` to check as other places. This impacts the timeout value on uploading the tarball, where a logged in user should have a connection timeout value of 60, but actually it is 15, and thus the upload will fail if it takes more than 15 seconds. Tested: Without the change, it fails to upload a tarball with 64M and times out at 15 seconds. With the fix, the upload is successful. Signed-off-by: Lei YU <yulei.sh@bytedance.com> Change-Id: I5e7c9e5d1f4c48ec604afb574ceda9ecc3f1cbc3
2021-12-28Move to common variantEd Tanous1-6/+5
This saves approximately 34kB in the compressed binary size of bmcweb due to reduced template instantiations. This amounts to a 2.5% reduction in the overall size. Note, there were a few places where we broke const-correctness in the form of pulling a non-const reference out of a const variant. This new variant now requires const correctness, so some consts are added where required. Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I6a60c8881c1268627eedb4ffddf16689dc5f6ed2
2021-12-22Make routing capture by const referenceEd Tanous1-4/+5
Where possible, we should avoid doing async_method_calls that capture by mutable value. Tested: Ran redfish/v1 and webui. Both appear to function. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I3065a230568ac13f63ce030b6f19eabba1ece5fe
2021-12-21Skip contentLength check in insecure-disable-authJunLin Chen1-1/+1
If we update image via POST /redfish/v1/UpdateService. Because there is no need to establish session in insecure-disable-auth, This restricts unauthenticated users upload sizes cause POST image fail. (image always greater than limit). According to https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/30994 it should not be checked this when disable-auth condition is enabled. Test: curl -k -X POST -T <image_path> "https://<bmcip>/redfish/v1/UpdateService" Return { "@odata.id": "/redfish/v1/TaskService/Tasks/1", "@odata.type": "#Task.v1_4_3.Task", "Id": "1", "TaskState": "Running", "TaskStatus": "OK" } Signed-off-by: JunLin Chen <Jun-Lin.Chen@quantatw.com> Change-Id: Iecb1cdc0213958e7d6191801043010b0ae10433d
2021-12-15Implement connection limitEd Tanous1-7/+9
Now that we rely on normal steady_timer, bmcweb doesn't limit http connections. This commit moves the connectionCount variable out of the debug ifdefs, and into the "normal" build. Then additionally, add a check to ensure that less than 100 connections are started at a time. This count is intended to match the code in timer_queue.hpp that limited this to 100 timers at a given time. Tested: /redfish/v1 returns properly. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I93ceaf8319d09d911b36cb7b21bba0cf64a9f7b8