Skip to content

Commit

Permalink
Treat HTTP 204 as error (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
fklebert committed Apr 26, 2024
1 parent 7048c0c commit cbe5040
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ on each platform:
* [macOS `add-generic-password`](https://www.netmeister.org/blog/keychain-passwords.html)
* [Windows `cmdkey`](https://www.scriptinglibrary.com/languages/powershell/how-to-manage-secrets-and-passwords-with-credentialmanager-and-powershell/)

## Client Result Code Handling

Both clients (Python and C++) will treat any HTTP response code other than `200` as an error since zserio services are expected to return a parsable response object. The client will throw an exception with a descriptive message if the response code is not `200`.

In case applications want to utilize for example the `204 (No Content)` response code, they have to catch the exception and handle it accordingly.

## Swagger User Interface

If you have installed `pip install "connexion[swagger-ui]"`, you can view
Expand Down
2 changes: 1 addition & 1 deletion libs/zswagcl/src/openapi-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ std::string OpenAPIClient::call(const std::string& methodIdent,
auto result = resultFuture.get();
httpcl::log().debug("{} Response received (code {}, content length {} bytes).", debugContext, result.status, result.content.size());

if (result.status >= 200 && result.status < 300) {
if (result.status == 200) {
return std::move(result.content);
}

Expand Down

0 comments on commit cbe5040

Please sign in to comment.