28 "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
47 const char*
methods[] = {
"?",
"GET",
"HEAD",
"POST",
48 "PUT",
"DELETE",
"TRACE",
"OPTIONS",
49 "CONNECT",
"PATCH",
nullptr};
87 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
90 (*it)->active =
false;
103 if (value !=
nullptr) {
107 "HttpHeader::put - did not add HttpHeaderLine for %s",
123 DlnaInfo,
"HttpHeader::put - value ignored because it is null for %s",
150 char* key = (
char*)line;
154 const char* value = line + pos + 1;
155 if (value[0] ==
' ') {
156 value = line + pos + 2;
158 return put((
const char*)key, value);
162 const char*
get(
const char* key) {
163 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
168 return line->
active ? result :
nullptr;
182 if (header ==
nullptr) {
184 "the value must not be null");
195 "HttpHeader::writeHeaderLine - ignored because value is null");
208 int len = strnlen(msg, 200);
240 if (in.connected()) {
241 if (in.available() == 0) {
244 while (in.available() == 0) {
246 if (count++>5)
break;
251 while (in.available()) {
269 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
311 if (key !=
nullptr) {
312 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
314 if (pt !=
nullptr && pt->
key.
c_str() !=
nullptr) {
324 "HttpHeader::headerLine - new line created for %s", key);
327 lines.push_back(newLine);
332 "The key must not be null");
339 for (
int j = 0;
methods[j] !=
nullptr; j++) {
340 const char* action =
methods[j];
341 int len = strlen(action);
342 if (strncmp(action, line, len) == 0) {
378 strncat(msg, method_str, 200);
379 strncat(msg,
" ", 200);
381 strncat(msg,
" ", 200);
383 strncat(msg,
CRLF, 200);
393 int space1 = line_str.
indexOf(
" ");
394 int space2 = line_str.
indexOf(
" ", space1 + 1);
429 while (strlen(line) != 0) {
455 int space1 = line_str.
indexOf(
' ', 0);
456 int space2 = line_str.
indexOf(
' ', space1 + 1);
464 status.
substring(line_str, space1 + 1, space2);
We read a single line. A terminating 0 is added to the string to make it compliant for c string funct...
Definition: HttpLineReader.h:13
virtual int readlnInternal(Stream &client, uint8_t *str, int len, bool incl_nl=true)
Definition: HttpLineReader.h:18
Double linked list.
Definition: List.h:19
void log(DlnaLogLevel current_level, const char *fmt...)
Print log message.
Definition: Logger.h:40
A simple wrapper to provide string functions on char*. If the underlying char* is a const we do not a...
Definition: StrView.h:25
virtual bool equalsIgnoreCase(const char *alt)
Compares the string ignoring the case.
Definition: StrView.h:575
virtual bool isEmpty()
checks if the string is empty
Definition: StrView.h:373
virtual int indexOf(const char c, int start=0)
Definition: StrView.h:267
virtual int length()
Definition: StrView.h:370
virtual void trim()
remove leading and traling spaces
Definition: StrView.h:510
virtual void substring(StrView &from, int start, int end)
copies a substring into the current string
Definition: StrView.h:483
virtual void ltrim()
remove leading spaces
Definition: StrView.h:526
virtual bool isNewLine()
Definition: StrView.h:375
String implementation which keeps the data on the heap. We grow the allocated memory only if the copy...
Definition: Str.h:22
const char * c_str()
provides the string value as const char*
Definition: Str.h:188
Definition: Allocator.h:6
const char * CONTENT_TYPE
Definition: HttpHeader.h:16
const char * IDENTITY
Definition: HttpHeader.h:31
const char * DEFAULT_AGENT
Definition: HttpHeader.h:27
const char * CON_KEEP_ALIVE
Definition: HttpHeader.h:20
const int MaxHeaderLineLength
Definition: HttpHeader.h:13
@ DlnaDebug
Definition: Logger.h:16
@ DlnaInfo
Definition: Logger.h:16
@ DlnaWarning
Definition: Logger.h:16
@ DlnaError
Definition: Logger.h:16
const char * methods[]
Definition: HttpHeader.h:47
const char * CONTENT_LENGTH
Definition: HttpHeader.h:17
const char * CON_CLOSE
Definition: HttpHeader.h:19
const char * HOST_C
Definition: HttpHeader.h:29
TinyMethodID
Definition: HttpHeader.h:35
@ T_TRACE
Definition: HttpHeader.h:42
@ T_DELETE
Definition: HttpHeader.h:41
@ T_CONNECT
Definition: HttpHeader.h:44
@ T_UNDEFINED
Definition: HttpHeader.h:36
@ T_OPTIONS
Definition: HttpHeader.h:43
@ T_HEAD
Definition: HttpHeader.h:38
@ T_GET
Definition: HttpHeader.h:37
@ T_PUT
Definition: HttpHeader.h:40
@ T_POST
Definition: HttpHeader.h:39
@ T_PATCH
Definition: HttpHeader.h:45
const char * TRANSFER_ENCODING
Definition: HttpHeader.h:21
const char * SUCCESS
Definition: HttpHeader.h:25
const char * ACCEPT
Definition: HttpHeader.h:23
const char * ACCEPT_ENCODING
Definition: HttpHeader.h:30
LoggerClass DlnaLogger
Definition: Logger.cpp:5
const char * CHUNKED
Definition: HttpHeader.h:22
const char * ACCEPT_ALL
Definition: HttpHeader.h:24
const char * USER_AGENT
Definition: HttpHeader.h:26
const char * CONNECTION
Definition: HttpHeader.h:18
const char * LOCATION
Definition: HttpHeader.h:32