Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
c54a920d
Commit
c54a920d
authored
Nov 10, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/httpd: make enum strictly-typed
parent
83f8eeec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
HttpdClient.cxx
src/output/plugins/httpd/HttpdClient.cxx
+12
-12
HttpdClient.hxx
src/output/plugins/httpd/HttpdClient.hxx
+3
-3
No files found.
src/output/plugins/httpd/HttpdClient.cxx
View file @
c54a920d
...
...
@@ -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
<
Mutex
>
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
;
...
...
src/output/plugins/httpd/HttpdClient.hxx
View file @
c54a920d
...
...
@@ -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
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment