Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-pico
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-pico
Commits
38bcf4f9
Unverified
Commit
38bcf4f9
authored
Aug 29, 2022
by
Earle F. Philhower, III
Committed by
GitHub
Aug 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor WebServer style/unused var cleanup (#810)
parent
486caf42
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
16 deletions
+7
-16
libraries/WebServer/src/HTTPServer.cpp
libraries/WebServer/src/HTTPServer.cpp
+3
-10
libraries/WebServer/src/Parsing.cpp
libraries/WebServer/src/Parsing.cpp
+4
-6
No files found.
libraries/WebServer/src/HTTPServer.cpp
View file @
38bcf4f9
...
...
@@ -43,6 +43,7 @@ static const char Content_Length[] = "Content-Length";
HTTPServer
::
HTTPServer
()
:
_corsEnabled
(
false
)
,
_currentClient
(
nullptr
)
,
_currentMethod
(
HTTP_ANY
)
,
_currentVersion
(
0
)
,
_currentStatus
(
HC_NONE
)
...
...
@@ -109,18 +110,15 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
char
toencodeLen
=
strlen
(
username
)
+
strlen
(
password
)
+
1
;
char
*
toencode
=
new
char
[
toencodeLen
+
1
];
if
(
toencode
==
NULL
)
{
authReq
=
""
;
return
false
;
}
char
*
encoded
=
new
char
[
base64_encode_expected_len
(
toencodeLen
)
+
1
];
if
(
encoded
==
NULL
)
{
authReq
=
""
;
delete
[]
toencode
;
return
false
;
}
sprintf
(
toencode
,
"%s:%s"
,
username
,
password
);
if
(
base64_encode_chars
(
toencode
,
toencodeLen
,
encoded
)
>
0
&&
authReq
==
encoded
)
{
authReq
=
""
;
delete
[]
toencode
;
delete
[]
encoded
;
return
true
;
...
...
@@ -132,7 +130,6 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
log_v
(
"%s"
,
authReq
.
c_str
());
String
_username
=
_extractParam
(
authReq
,
F
(
"username=
\"
"
),
'\"'
);
if
(
!
_username
.
length
()
||
_username
!=
String
(
username
))
{
authReq
=
""
;
return
false
;
}
// extracting required parameters for RFC 2069 simpler Digest
...
...
@@ -143,11 +140,9 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
String
_opaque
=
_extractParam
(
authReq
,
F
(
"opaque=
\"
"
),
'\"'
);
if
((
!
_realm
.
length
())
||
(
!
_nonce
.
length
())
||
(
!
_uri
.
length
())
||
(
!
_response
.
length
())
||
(
!
_opaque
.
length
()))
{
authReq
=
""
;
return
false
;
}
if
((
_opaque
!=
_sopaque
)
||
(
_nonce
!=
_snonce
)
||
(
_realm
!=
_srealm
))
{
authReq
=
""
;
return
false
;
}
// parameters for the RFC 2617 newer Digest
...
...
@@ -179,11 +174,9 @@ bool HTTPServer::authenticate(const char * username, const char * password) {
}
log_v
(
"The Proper response=%s"
,
_responsecheck
.
c_str
());
if
(
_response
==
_responsecheck
)
{
authReq
=
""
;
return
true
;
}
}
authReq
=
""
;
}
return
false
;
}
...
...
@@ -440,7 +433,7 @@ void HTTPServer::sendContent(const char* content, size_t contentLength) {
const
char
*
footer
=
"
\r\n
"
;
if
(
_chunked
)
{
char
chunkSize
[
11
];
sprintf
(
chunkSize
,
"%x%s"
,
contentLength
,
footer
);
sprintf
(
chunkSize
,
"%x%s"
,
(
unsigned
int
)
contentLength
,
footer
);
_currentClientWrite
(
chunkSize
,
strlen
(
chunkSize
));
}
_currentClientWrite
(
content
,
contentLength
);
...
...
@@ -460,7 +453,7 @@ void HTTPServer::sendContent_P(PGM_P content, size_t size) {
const
char
*
footer
=
"
\r\n
"
;
if
(
_chunked
)
{
char
chunkSize
[
11
];
sprintf
(
chunkSize
,
"%x%s"
,
size
,
footer
);
sprintf
(
chunkSize
,
"%x%s"
,
(
unsigned
int
)
size
,
footer
);
_currentClientWrite
(
chunkSize
,
strlen
(
chunkSize
));
}
_currentClientWrite_P
(
content
,
size
);
...
...
libraries/WebServer/src/Parsing.cpp
View file @
38bcf4f9
...
...
@@ -514,9 +514,8 @@ readfile:
_uploadWriteByte
(
0x0A
);
_uploadWriteByte
((
uint8_t
)(
'-'
));
_uploadWriteByte
((
uint8_t
)(
'-'
));
uint32_t
j
=
0
;
while
(
j
<
i
)
{
_uploadWriteByte
(
endBuf
[
j
++
]);
for
(
uint32_t
j
=
0
;
j
<
i
;
j
++
)
{
_uploadWriteByte
(
endBuf
[
j
]);
}
goto
readfile
;
}
...
...
@@ -545,9 +544,8 @@ readfile:
_uploadWriteByte
(
0x0A
);
_uploadWriteByte
((
uint8_t
)(
'-'
));
_uploadWriteByte
((
uint8_t
)(
'-'
));
uint32_t
i
=
0
;
while
(
i
<
boundary
.
length
())
{
_uploadWriteByte
(
endBuf
[
i
++
]);
for
(
uint32_t
j
=
0
;
j
<
boundary
.
length
();
j
++
)
{
_uploadWriteByte
(
endBuf
[
j
]);
}
argByte
=
_uploadReadByte
(
client
);
goto
readfile
;
...
...
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