| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c221d22 commit 50c0f59
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -529,9 +529,15 @@ void HTTPConnection::loop() { | |||
| 529 | 529 | // Now we need to check if we can use keep-alive to reuse the SSL connection | |
| 530 | 530 | // However, if the client did not set content-size or defined connection: close, | |
| 531 | 531 | // we have no chance to do so. | |
| 532 | + // Also, the programmer may have explicitly set Connection: close for the response. | ||
| 533 | + std::string hConnection = res.getHeader("Connection"); | ||
| 534 | + if (hConnection == "close") { | ||
| 535 | + _isKeepAlive = false; | ||
| 536 | + } | ||
| 532 | 537 | if (!_isKeepAlive) { | |
| 533 | 538 | // No KeepAlive -> We are done. Transition to next state. | |
| 534 | 539 | if (!isClosed()) { | |
| 540 | + res.finalize(); | ||
| 535 | 541 | _connectionState = STATE_BODY_FINISHED; | |
| 536 | 542 | } | |
| 537 | 543 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,15 @@ void HTTPResponse::setHeader(std::string const &name, std::string const &value) | |||
| 52 | 52 | _headers.set(new HTTPHeader(name, value)); | |
| 53 | 53 | } | |
| 54 | 54 | ||
| 55 | + std::string HTTPResponse::getHeader(std::string const &name) { | ||
| 56 | + HTTPHeader * h = _headers.get(name); | ||
| 57 | + if (h != NULL) { | ||
| 58 | + return h->_value; | ||
| 59 | + } else { | ||
| 60 | + return std::string(); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | + | ||
| 55 | 64 | bool HTTPResponse::isHeaderWritten() { | |
| 56 | 65 | return _headerWritten; | |
| 57 | 66 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ class HTTPResponse : public Print { | |||
| 32 | 32 | uint16_t getStatusCode(); | |
| 33 | 33 | std::string getStatusText(); | |
| 34 | 34 | void setHeader(std::string const &name, std::string const &value); | |
| 35 | + std::string getHeader(std::string const &name); | ||
| 35 | 36 | bool isHeaderWritten(); | |
| 36 | 37 | ||
| 37 | 38 | void printStd(std::string const &str); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments