diff --git a/src/output/plugins/httpd/HttpdClient.cxx b/src/output/plugins/httpd/HttpdClient.cxx index 4beba3b25..74f00a50c 100644 --- a/src/output/plugins/httpd/HttpdClient.cxx +++ b/src/output/plugins/httpd/HttpdClient.cxx @@ -54,9 +54,9 @@ HttpdClient::LockClose() void HttpdClient::BeginResponse() { - assert(state != RESPONSE); + assert(state != State::RESPONSE); - state = RESPONSE; + state = State::RESPONSE; current_page = nullptr; if (!head_method) @@ -69,9 +69,9 @@ HttpdClient::BeginResponse() bool HttpdClient::HandleLine(const char *line) { - assert(state != RESPONSE); + assert(state != State::RESPONSE); - if (state == REQUEST) { + if (state == State::REQUEST) { if (memcmp(line, "HEAD /", 6) == 0) { line += 6; head_method = true; @@ -96,7 +96,7 @@ HttpdClient::HandleLine(const char *line) } /* after the request line, request headers follow */ - state = HEADERS; + state = State::HEADERS; return true; } else { if (*line == 0) { @@ -137,7 +137,7 @@ HttpdClient::SendResponse() AllocatedString<> allocated = nullptr; const char *response; - assert(state == RESPONSE); + assert(state == State::RESPONSE); if (dlna_streaming_requested) { snprintf(buffer, sizeof(buffer), @@ -198,7 +198,7 @@ HttpdClient::HttpdClient(HttpdOutput &_httpd, UniqueSocketDescriptor _fd, void HttpdClient::ClearQueue() { - assert(state == RESPONSE); + assert(state == State::RESPONSE); while (!pages.empty()) { #ifndef NDEBUG @@ -216,7 +216,7 @@ HttpdClient::ClearQueue() void HttpdClient::CancelQueue() { - if (state != RESPONSE) + if (state != State::RESPONSE) return; ClearQueue(); @@ -257,7 +257,7 @@ HttpdClient::TryWrite() { const std::lock_guard protect(httpd.mutex); - assert(state == RESPONSE); + assert(state == State::RESPONSE); if (current_page == nullptr) { if (pages.empty()) { @@ -369,7 +369,7 @@ HttpdClient::TryWrite() void HttpdClient::PushPage(PagePtr page) { - if (state != RESPONSE) + if (state != State::RESPONSE) /* the client is still writing the HTTP request */ return; @@ -410,7 +410,7 @@ HttpdClient::OnSocketReady(unsigned flags) noexcept BufferedSocket::InputResult HttpdClient::OnSocketInput(void *data, size_t length) { - if (state == RESPONSE) { + if (state == State::RESPONSE) { LogWarning(httpd_output_domain, "unexpected input from client"); LockClose(); @@ -435,7 +435,7 @@ HttpdClient::OnSocketInput(void *data, size_t length) return InputResult::CLOSED; } - if (state == RESPONSE) { + if (state == State::RESPONSE) { if (!SendResponse()) return InputResult::CLOSED; diff --git a/src/output/plugins/httpd/HttpdClient.hxx b/src/output/plugins/httpd/HttpdClient.hxx index fd65637df..444a49ba4 100644 --- a/src/output/plugins/httpd/HttpdClient.hxx +++ b/src/output/plugins/httpd/HttpdClient.hxx @@ -46,7 +46,7 @@ class HttpdClient final /** * The current state of the client. */ - enum { + enum class State { /** reading the request line */ REQUEST, @@ -55,7 +55,7 @@ class HttpdClient final /** sending the HTTP response */ RESPONSE, - } state = REQUEST; + } state = State::REQUEST; /** * A queue of #Page objects to be sent to the client. @@ -160,7 +160,7 @@ public: bool HandleLine(const char *line); /** - * Switch the client to the "RESPONSE" state. + * Switch the client to #State::RESPONSE. */ void BeginResponse();