28 "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)";
50const char*
methods[] = {
"?",
"GET",
"HEAD",
"POST",
51 "PUT",
"DELETE",
"TRACE",
"OPTIONS",
52 "CONNECT",
"PATCH",
"UNSUBSCRIBE",
"SUBSCRIBE",
"NOTIFY",
nullptr};
90 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
93 (*it)->active =
false;
106 if (value !=
nullptr) {
110 "HttpHeader::put - did not add HttpHeaderLine for %s",
149 char* key = (
char*)line;
153 const char* value = line + pos + 1;
154 if (value[0] ==
' ') {
155 value = line + pos + 2;
157 return put((
const char*)key, value);
161 const char*
get(
const char* key) {
162 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
167 return line->
active ? result :
nullptr;
181 if (header ==
nullptr) {
183 "the value must not be null");
194 "HttpHeader::writeHeaderLine - ignored because value is null");
207 int len = strnlen(msg, 200);
239 if (in.connected()) {
241 if (in.available() == 0) {
243 uint64_t end = millis() + in.getTimeout();
244 while (in.available() == 0) {
246 if (millis()>end)
break;
251 while (in.available()) {
270 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
312 if (key !=
nullptr) {
313 for (
auto it =
lines.begin(); it !=
lines.end(); ++it) {
315 if (pt !=
nullptr && pt->
key.
c_str() !=
nullptr) {
325 "HttpHeader::headerLine - new line created for %s", key);
328 lines.push_back(newLine);
333 "The key must not be null");
340 for (
int j = 0;
methods[j] !=
nullptr; j++) {
341 const char* action =
methods[j];
342 int len = strlen(action);
343 if (strncmp(action, line, len) == 0) {
379 strncat(msg, method_str, 200);
380 strncat(msg,
" ", 200);
382 strncat(msg,
" ", 200);
384 strncat(msg,
CRLF, 200);
394 int space1 = line_str.
indexOf(
" ");
395 int space2 = line_str.
indexOf(
" ", space1 + 1);
430 while (strlen(line) != 0) {
456 int space1 = line_str.
indexOf(
' ', 0);
457 int space2 = line_str.
indexOf(
' ', space1 + 1);
465 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
A simple wrapper to provide string functions on char*. If the underlying char* is a const we do not a...
Definition: StrView.h:18
virtual void substrView(StrView &from, int start, int end)
copies a substring into the current string
Definition: StrView.h:505
virtual bool isEmpty()
checks if the string is empty
Definition: StrView.h:383
virtual int indexOf(const char c, int start=0)
Definition: StrView.h:274
virtual int length()
Definition: StrView.h:380
virtual void ltrim()
remove leading spaces
Definition: StrView.h:548
virtual bool isNewLine()
Definition: StrView.h:385
Heap-backed string utility used throughout tiny_dlna.
Definition: Str.h:27
bool equalsIgnoreCase(const char *other) const
Case-insensitive equality with C-string.
Definition: Str.h:183
void trim()
Trim spaces on both ends.
Definition: Str.h:235
void substrView(StrView &from, int start, int end)
Assign substring view from StrView [start,end)
Definition: Str.h:69
const char * c_str() const
C-string pointer to internal buffer.
Definition: Str.h:88
Definition: Allocator.h:13
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
const char * methods[]
Definition: HttpHeader.h:50
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_UNSUBSCRIBE
Definition: HttpHeader.h:46
@ T_UNDEFINED
Definition: HttpHeader.h:36
@ T_OPTIONS
Definition: HttpHeader.h:43
@ T_SUBSCRIBE
Definition: HttpHeader.h:47
@ 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
@ T_NOTIFY
Definition: HttpHeader.h:48
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
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