[cpp-sp] branch main updated: Relay HTTP status code through exception.
Codeberg
noreply at shibboleth.net
Tue Feb 10 18:23:44 UTC 2026
This is an automated email from the git hooks/post-receive script.
codeberg pushed a commit to branch main
in repository cpp-sp.
View the commit online:
https://codeberg.org/Shibboleth/cpp-sp/commit/b0786791acaf63b6a1187f26b939a56942026582
The following commit(s) were added to refs/heads/main by this push:
new b0786791 Relay HTTP status code through exception.
b0786791 is described below
commit b0786791acaf63b6a1187f26b939a56942026582
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Feb 10 13:23:31 2026 -0500
Relay HTTP status code through exception.
---
shibsp/exceptions.cpp | 8 ++++----
shibsp/exceptions.h | 6 +++---
shibsp/remoting/impl/CurlHTTPRemotingService.cpp | 6 +++++-
shibsp/remoting/impl/WinHTTPRemotingService.cpp | 8 +++++---
4 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/shibsp/exceptions.cpp b/shibsp/exceptions.cpp
index 5ad2b83a..e7395b5b 100644
--- a/shibsp/exceptions.cpp
+++ b/shibsp/exceptions.cpp
@@ -35,13 +35,13 @@ const char AgentException::HANDLER_TYPE_PROP_NAME[] = "handlerType";
const char AgentException::EVENT_PROP_NAME[] = "event";
const char AgentException::TARGET_PROP_NAME[] = "target";
-AgentException::AgentException(const char* msg) : m_status(HTTPResponse::SHIBSP_HTTP_STATUS_ERROR)
+AgentException::AgentException(const char* msg) : m_status(0)
{
if (msg)
m_msg = msg;
}
-AgentException::AgentException(const string& msg) : m_status(HTTPResponse::SHIBSP_HTTP_STATUS_ERROR), m_msg(msg)
+AgentException::AgentException(const string& msg) : m_status(0), m_msg(msg)
{
}
@@ -54,12 +54,12 @@ const char* AgentException::what() const noexcept
return m_msg.c_str();
}
-int AgentException::getStatusCode() const noexcept
+long AgentException::getStatusCode() const noexcept
{
return m_status;
}
-void AgentException::setStatusCode(int code) noexcept
+void AgentException::setStatusCode(long code) noexcept
{
m_status = code;
}
diff --git a/shibsp/exceptions.h b/shibsp/exceptions.h
index 5a6c59d5..c820c848 100644
--- a/shibsp/exceptions.h
+++ b/shibsp/exceptions.h
@@ -86,14 +86,14 @@ namespace shibsp {
*
* @return status code
*/
- int getStatusCode() const noexcept;
+ long getStatusCode() const noexcept;
/**
* Sets the HTTP status code for the error condition if not the default of 500.
*
* @param code status code
*/
- void setStatusCode(int code) noexcept;
+ void setStatusCode(long code) noexcept;
/**
* Gets the properties attached to this exception.
@@ -148,7 +148,7 @@ namespace shibsp {
static const char TARGET_PROP_NAME[];
private:
- int m_status;
+ long m_status;
std::string m_msg;
std::unordered_map<std::string,std::string> m_props;
};
diff --git a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
index c250a323..16cd21a5 100644
--- a/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/CurlHTTPRemotingService.cpp
@@ -449,8 +449,12 @@ void CurlOperation::send(const char* path, istream& in, ostream& out)
}
if (code != CURLE_OK) {
- throw RemotingException("Remote request failed at " + url + ": " +
+ long status = 0;
+ curl_easy_getinfo(m_handle, CURLINFO_RESPONSE_CODE, &status);
+ RemotingException ex("Remote request failed at " + url + ": " +
(curl_errorbuf[0] ? curl_errorbuf : "no further information available"));
+ ex.setStatusCode(status);
+ throw ex;
}
// This won't prevent every possible failed connection from being kept, but it's something.
diff --git a/shibsp/remoting/impl/WinHTTPRemotingService.cpp b/shibsp/remoting/impl/WinHTTPRemotingService.cpp
index bd6bab61..5c6c0adf 100644
--- a/shibsp/remoting/impl/WinHTTPRemotingService.cpp
+++ b/shibsp/remoting/impl/WinHTTPRemotingService.cpp
@@ -497,14 +497,16 @@ void WinHTTPRemotingService::send(const char* path, istream& input, ostream& out
//
if (!WinHttpQueryHeaders(request, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, nullptr, &statusCode, &statusCodeSize, nullptr)) {
m_log.crit("Send. Failed to Query response from %s : %d", path, GetLastError());
- throw runtime_error("Send failed");
+ throw RemotingException("Send failed");
}
if (statusCode != HTTP_STATUS_OK) {
//
- // TODO - something meaningfull
+ // TODO - something meaningful
//
m_log.crit("Send. Bad status from %s : %d", path, statusCode);
- throw RemotingException("Send failed");
+ RemotingException ex("Send failed");
+ ex.setStatusCode(statusCode);
+ throw ex;
}
DWORD bufferSize = 0;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list