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