mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Added in Steven Van Ingelgem's patch to add an HTTP status string to the HTTP server.
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402994
This commit is contained in:
parent
28c356d728
commit
1dd9e4dcf4
@ -90,6 +90,7 @@ namespace dlib
|
||||
key_value_map cookies;
|
||||
key_value_map headers;
|
||||
unsigned short http_return;
|
||||
std::string http_return_status;
|
||||
};
|
||||
|
||||
|
||||
@ -348,6 +349,11 @@ namespace dlib
|
||||
my_fault = false;
|
||||
key_value_map& new_cookies = outgoing.cookies;
|
||||
key_value_map& response_headers = outgoing.headers;
|
||||
|
||||
// Set some defaults
|
||||
outgoing.http_return = 200;
|
||||
outgoing.http_return_status = "OK";
|
||||
|
||||
// if there wasn't a problem with the input stream at some point
|
||||
// then lets trigger this request callback.
|
||||
std::string result;
|
||||
@ -387,7 +393,7 @@ namespace dlib
|
||||
response_headers["Content-Length"] = os.str();
|
||||
}
|
||||
|
||||
out << "HTTP/1.0 " << outgoing.http_return << " OK\r\n";
|
||||
out << "HTTP/1.0 " << outgoing.http_return << " " << outgoing.http_return_status << "\r\n";
|
||||
|
||||
// Set any new headers
|
||||
for( typename key_value_map::const_iterator ci = response_headers.begin(); ci != response_headers.end(); ++ci )
|
||||
|
@ -112,6 +112,7 @@ namespace dlib
|
||||
key_value_map cookies;
|
||||
key_value_map headers;
|
||||
unsigned short http_return;
|
||||
std::string http_return_status;
|
||||
};
|
||||
|
||||
private:
|
||||
@ -151,6 +152,7 @@ namespace dlib
|
||||
- outgoing.cookies.size() == 0
|
||||
- outgoing.headers.size() == 0
|
||||
- outgoing.http_return == 200
|
||||
- outgoing.http_return_status == "OK"
|
||||
ensures
|
||||
- This function returns the HTML page to be displayed as the response to this request.
|
||||
- this function will not call clear()
|
||||
@ -160,7 +162,8 @@ namespace dlib
|
||||
- #outgoing.headers == a set of additional headers you wish to appear in the
|
||||
HTTP response to this request. (This may be empty, the minimum needed headers
|
||||
will be added automatically if you don't set them)
|
||||
- outgoing.http_return may be set to override the default HTTP return code of 200
|
||||
- outgoing.http_return and outgoing.http_return_status may be set to override the
|
||||
default HTTP return code of 200 OK
|
||||
throws
|
||||
- does not throw any exceptions
|
||||
!*/
|
||||
|
Loading…
Reference in New Issue
Block a user