28 "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
48 const char*
methods[] = {
"?",
"GET",
"HEAD",
"POST",
49 "PUT",
"DELETE",
"TRACE",
"OPTIONS",
50 "CONNECT",
"PATCH",
"SUBSCRIBE",
nullptr};
88 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
91 (*it)->active =
false;
104 if (value !=
nullptr) {
108 "HttpHeader::put - did not add HttpHeaderLine for %s",
124 DlnaInfo,
"HttpHeader::put - value ignored because it is null for %s",
151 char* key = (
char*)line;
155 const char* value = line + pos + 1;
156 if (value[0] ==
' ') {
157 value = line + pos + 2;
159 return put((
const char*)key, value);
163 const char*
get(
const char* key) {
164 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
169 return line->
active ? result :
nullptr;
183 if (header ==
nullptr) {
185 "the value must not be null");
196 "HttpHeader::writeHeaderLine - ignored because value is null");
209 int len = strnlen(msg, 200);
241 if (in.connected()) {
243 if (in.available() == 0) {
245 uint64_t end = millis() + in.getTimeout();
246 while (in.available() == 0) {
248 if (millis()>end)
break;
253 while (in.available()) {
271 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
313 if (key !=
nullptr) {
314 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
316 if (pt !=
nullptr && pt->
key.
c_str() !=
nullptr) {
326 "HttpHeader::headerLine - new line created for %s", key);
329 lines.push_back(newLine);
334 "The key must not be null");
341 for (
int j = 0;
methods[j] !=
nullptr; j++) {
342 const char* action =
methods[j];
343 int len = strlen(action);
344 if (strncmp(action, line, len) == 0) {
380 strncat(msg, method_str, 200);
381 strncat(msg,
" ", 200);
383 strncat(msg,
" ", 200);
385 strncat(msg,
CRLF, 200);
395 int space1 = line_str.
indexOf(
" ");
396 int space2 = line_str.
indexOf(
" ", space1 + 1);
431 while (strlen(line) != 0) {
457 int space1 = line_str.
indexOf(
' ', 0);
458 int space2 = line_str.
indexOf(
' ', space1 + 1);
466 status.
substrView(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:19
virtual void substrView(StrView &from, int start, int end)
copies a substring into the current string
Definition: StrView.h:486
virtual bool equalsIgnoreCase(const char *alt)
Compares the string ignoring the case.
Definition: StrView.h:578
virtual bool isEmpty()
checks if the string is empty
Definition: StrView.h:376
virtual int indexOf(const char c, int start=0)
Definition: StrView.h:269
virtual int length()
Definition: StrView.h:373
virtual void trim()
remove leading and traling spaces
Definition: StrView.h:513
virtual void ltrim()
remove leading spaces
Definition: StrView.h:529
virtual bool isNewLine()
Definition: StrView.h:378
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:48
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_SUBSCRIBE
Definition: HttpHeader.h:46
@ 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