|
10 | 10 | namespace audio_tools {
|
11 | 11 |
|
12 | 12 | // Class Configuration
|
13 |
| -const int MaxHeaderLineLength = 200; |
| 13 | +const int MaxHeaderLineLength = 240; |
14 | 14 |
|
15 | 15 | // Define relevant header content
|
16 | 16 | const char* CONTENT_TYPE = "Content-Type";
|
@@ -87,6 +87,7 @@ class HttpHeader {
|
87 | 87 |
|
88 | 88 | HttpHeader& put(const char* key, const char* value){
|
89 | 89 | if (value!=nullptr && strlen(value)>0){
|
| 90 | + LOGD("HttpHeader::put %s %s", key, value); |
90 | 91 | HttpHeaderLine *hl = headerLine(key);
|
91 | 92 | if (hl==nullptr){
|
92 | 93 | LOGE("HttpHeader::put - did not add HttpHeaderLine for %s", key);
|
@@ -138,15 +139,15 @@ class HttpHeader {
|
138 | 139 | if (value[0]==' '){
|
139 | 140 | value = line+pos+2;
|
140 | 141 | }
|
141 |
| - return put((const char*)key,value); |
| 142 | + return put((const char*)key, value); |
142 | 143 | }
|
143 | 144 |
|
144 | 145 | // determines a header value with the key
|
145 | 146 | const char* get(const char* key){
|
146 | 147 | for (auto it = lines.begin() ; it != lines.end(); ++it){
|
147 | 148 | HttpHeaderLine *line = *it;
|
148 | 149 | line->key.trim();
|
149 |
| - if (Str(line->key).equalsIgnoreCase(key)){ |
| 150 | + if (line->key.equalsIgnoreCase(key)){ |
150 | 151 | const char* result = line->value.c_str();
|
151 | 152 | return line->active ? result : nullptr;
|
152 | 153 | }
|
@@ -236,7 +237,7 @@ class HttpHeader {
|
236 | 237 | parse1stLine(line);
|
237 | 238 | while (in.available()){
|
238 | 239 | readLine(in, line, MaxHeaderLineLength);
|
239 |
| - if (isValidStatus()){ |
| 240 | + if (isValidStatus() || isRedirectStatus()){ |
240 | 241 | Str lineStr(line);
|
241 | 242 | lineStr.ltrim();
|
242 | 243 | if (lineStr.isEmpty()){
|
@@ -271,6 +272,9 @@ class HttpHeader {
|
271 | 272 | return status_code >= 200 && status_code < 300;
|
272 | 273 | }
|
273 | 274 |
|
| 275 | + bool isRedirectStatus() { |
| 276 | + return status_code >= 300 && status_code < 400; |
| 277 | + } |
274 | 278 |
|
275 | 279 | protected:
|
276 | 280 | int status_code = UNDEFINED;
|
@@ -299,7 +303,7 @@ class HttpHeader {
|
299 | 303 | for (auto it = lines.begin() ; it != lines.end(); ++it){
|
300 | 304 | HttpHeaderLine *pt = (*it);
|
301 | 305 | if (pt!=nullptr && pt->key.c_str()!=nullptr){
|
302 |
| - if (strcmp(pt->key.c_str(),key)==0){ |
| 306 | + if (pt->key.equalsIgnoreCase(key)){ |
303 | 307 | pt->active = true;
|
304 | 308 | return pt;
|
305 | 309 | }
|
|
0 commit comments