This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAsyncHTTPSRequest_Impl_Generic.h
2160 lines (1574 loc) · 42.5 KB
/
AsyncHTTPSRequest_Impl_Generic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/****************************************************************************************************************************
AsyncHTTPSRequest_Impl_Generic.h
For ESP32, future ESP8266
AsyncHTTPSRequest is a library for the ESP32, ESP8266 (not-yet ready)
Based on and modified from AsyncHTTPRequest Library (https://github.com/boblemaire/asyncHTTPrequest)
Built by Khoi Hoang https://github.com/khoih-prog/AsyncHTTPSRequest_Generic
Copyright (C) <2018> <Bob Lemaire, IoTaWatt, Inc.>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Version: 2.5.0
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 21/10/2021 Initial coding to support only ESP32
1.1.0 K Hoang 23/10/2021 Add support to ESP32-based WT32-ETH01 using LAN8720
1.1.1 K Hoang 29/11/2021 Auto detect ESP32 core version and improve connection time for WT32_ETH01
1.2.0 K Hoang 30/12/2021 Fix `multiple-definitions` linker error
1.3.0 K Hoang 23/01/2022 Enable compatibility with old code to include only AsyncHTTPSRequest_Generic.h
1.4.0 K Hoang 11/02/2022 Add support to new ESP32-S3. Add LittleFS support to ESP32-C3. Use core LittleFS
1.4.1 K Hoang 25/02/2022 Add example AsyncHTTPSRequest_ESP_Multi to demo connection to multiple addresses
2.0.0 K Hoang 27/02/2022 Breaking change to permit coexisting with AsyncHTTPRequest library. Add example to demo
2.0.1 K Hoang 24/03/2022 Increase DEFAULT_RX_TIMEOUT to 30s from 3s for slower networks
2.1.0 K Hoang 30/08/2022 Fix bug. Improve debug messages. Optimize code
2.1.1 K Hoang 09/09/2022 Fix ESP32 chipID for example `AsyncHTTPSRequest_ESP_WiFiManager`
2.1.2 K Hoang 18/09/2022 Fix bug and compiler error in some cases
2.1.3 K Hoang 18/10/2022 Not try to reconnect to the same host:port after connected
2.2.0 K Hoang 20/10/2022 Fix crash and memory leak
2.2.1 K Hoang 09/11/2022 Default to reconnect to the same host:port after connected for new HTTP sites
2.3.0 K Hoang 28/11/2022 Add support to ESP32 boards using LwIP ENC28J60 Ethernet
2.4.0 K Hoang 30/11/2022 Add support to ESP32 boards using LwIP W5500 Ethernet. Fix bug
2.5.0 K Hoang 31/01/2023 Add support to ESP32 using LwIP W6100 Ethernet. Fix bug of wrong reqStates and _parseURL()
*****************************************************************************************************************************/
#pragma once
#ifndef ASYNC_HTTPS_REQUEST_GENERIC_IMPL_H
#define ASYNC_HTTPS_REQUEST_GENERIC_IMPL_H
#include <AsyncTCP_SSL.h>
#define CANT_SEND_BAD_REQUEST F("Can't send() bad request")
#if !defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION)
// Not necessary if already defined in AsyncHTTPRequest library
// Merge xbuf
////////////////////////////////////////
xbuf::xbuf(const uint16_t segSize) : _head(nullptr), _tail(nullptr), _used(0), _free(0), _offset(0)
{
_segSize = (segSize + 3) & -4;//((segSize + 3) >> 2) << 2;
}
////////////////////////////////////////
xbuf::~xbuf()
{
flush();
}
////////////////////////////////////////
size_t xbuf::write(const uint8_t byte)
{
return write((uint8_t*) &byte, 1);
}
////////////////////////////////////////
size_t xbuf::write(const char* buf)
{
return write((uint8_t*)buf, strlen(buf));
}
////////////////////////////////////////
size_t xbuf::write(const String& string)
{
return write((uint8_t*)string.c_str(), string.length());
}
////////////////////////////////////////
size_t xbuf::write(const uint8_t* buf, const size_t len)
{
size_t supply = len;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
memcpy(_tail->data + ((_offset + _used) % _segSize), buf + (len - supply), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return len;
}
////////////////////////////////////////
size_t xbuf::write(xbuf* buf, const size_t len)
{
size_t supply = len;
if (supply > buf->available())
{
supply = buf->available();
}
size_t read = 0;
while (supply)
{
if (!_free)
{
addSeg();
}
size_t demand = _free < supply ? _free : supply;
read += buf->read(_tail->data + ((_offset + _used) % _segSize), demand);
_free -= demand;
_used += demand;
supply -= demand;
}
return read;
}
////////////////////////////////////////
uint8_t xbuf::read()
{
uint8_t byte = 0;
read((uint8_t*) &byte, 1);
return byte;
}
////////////////////////////////////////
uint8_t xbuf::peek()
{
uint8_t byte = 0;
peek((uint8_t*) &byte, 1);
return byte;
}
////////////////////////////////////////
size_t xbuf::read(uint8_t* buf, const size_t len)
{
size_t read = 0;
while (read < len && _used)
{
size_t supply = (_offset + _used) > _segSize ? _segSize - _offset : _used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, _head->data + _offset, chunk);
_offset += chunk;
_used -= chunk;
read += chunk;
if (_offset == _segSize)
{
remSeg();
_offset = 0;
}
}
if ( ! _used)
{
flush();
}
return read;
}
////////////////////////////////////////
size_t xbuf::peek(uint8_t* buf, const size_t len)
{
size_t read = 0;
xseg* seg = _head;
size_t offset = _offset;
size_t used = _used;
while (read < len && used)
{
size_t supply = (offset + used) > _segSize ? _segSize - offset : used;
size_t demand = len - read;
size_t chunk = supply < demand ? supply : demand;
memcpy(buf + read, seg->data + offset, chunk);
offset += chunk;
used -= chunk;
read += chunk;
if (offset == _segSize)
{
seg = seg->next;
offset = 0;
}
}
return read;
}
////////////////////////////////////////
size_t xbuf::available()
{
return _used;
}
////////////////////////////////////////
int xbuf::indexOf(const char target, const size_t begin)
{
char targetstr[2] = " ";
targetstr[0] = target;
return indexOf(targetstr, begin);
}
////////////////////////////////////////
int xbuf::indexOf(const char* target, const size_t begin)
{
size_t targetLen = strlen(target);
if (targetLen > _segSize || targetLen > _used)
return -1;
size_t searchPos = _offset + begin;
size_t searchEnd = _offset + _used - targetLen;
if (searchPos > searchEnd)
return -1;
size_t searchSeg = searchPos / _segSize;
xseg* seg = _head;
while (searchSeg)
{
seg = seg->next;
searchSeg --;
}
size_t segPos = searchPos % _segSize;
while (searchPos <= searchEnd)
{
size_t compLen = targetLen;
if (compLen <= (_segSize - segPos))
{
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
return searchPos - _offset;
}
}
else
{
size_t compLen = _segSize - segPos;
if (memcmp(target, seg->data + segPos, compLen) == 0)
{
compLen = targetLen - compLen;
if (memcmp(target + targetLen - compLen, seg->next->data, compLen) == 0)
{
return searchPos - _offset;
}
}
}
searchPos++;
segPos++;
if (segPos == _segSize)
{
seg = seg->next;
segPos = 0;
}
}
return -1;
}
////////////////////////////////////////
String xbuf::readStringUntil(const char target)
{
return readString(indexOf(target) + 1);
}
////////////////////////////////////////
String xbuf::readStringUntil(const char* target)
{
int index = indexOf(target);
if (index < 0)
return String();
return readString(index + strlen(target));
}
////////////////////////////////////////
String xbuf::readString(int endPos)
{
String result;
if ( ! result.reserve(endPos + 1))
{
return result;
}
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)_head->data[_offset++];
_used--;
if (_offset >= _segSize)
{
remSeg();
}
}
}
return result;
}
////////////////////////////////////////
String xbuf::peekString(int endPos)
{
String result;
xseg* seg = _head;
size_t offset = _offset;
if (endPos > _used)
{
endPos = _used;
}
if (endPos > 0 && result.reserve(endPos + 1))
{
while (endPos--)
{
result += (char)seg->data[offset++];
if ( offset >= _segSize)
{
seg = seg->next;
offset = 0;
}
}
}
return result;
}
////////////////////////////////////////
void xbuf::flush()
{
while (_head)
remSeg();
_tail = nullptr;
_offset = 0;
_used = 0;
_free = 0;
}
////////////////////////////////////////
void xbuf::addSeg()
{
if (_tail)
{
_tail->next = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail->next == NULL)
{
AHTTPS_LOGERROR(F("xbuf::addSeg: error new 1"));
}
else
{
// KH, Must check NULL here
_tail = _tail->next;
}
}
else
{
// KH, Must check NULL here
_tail = _head = (xseg*) new uint32_t[_segSize / 4 + 1];
if (_tail == NULL)
AHTTPS_LOGERROR(F("xbuf::addSeg: error new 2"));
}
// KH, Must check NULL here
if (_tail)
_tail->next = nullptr;
_free += _segSize;
}
////////////////////////////////////////
void xbuf::remSeg()
{
if (_head)
{
xseg *next = _head->next;
delete[] (uint32_t*) _head;
_head = next;
if ( ! _head)
{
_tail = nullptr;
}
}
_offset = 0;
}
#endif // #if !defined(ASYNC_HTTP_REQUEST_GENERIC_VERSION)
////////////////////////////////////////
////////////////////////////////////////
AsyncHTTPSRequest::AsyncHTTPSRequest(): _readyState(readyStateUnsent), _HTTPcode(0), _chunked(false),
_debug(DEBUG_IOTA_HTTP_SET)
, _timeout(DEFAULT_RX_TIMEOUT), _lastActivity(0), _requestStartTime(0), _requestEndTime(0), _URL(nullptr)
, _connectedHost(nullptr), _connectedPort(-1), _client(nullptr), _contentLength(0), _contentRead(0)
, _readyStateChangeCB(nullptr), _readyStateChangeCBarg(nullptr), _onDataCB(nullptr), _onDataCBarg(nullptr)
, _request(nullptr), _response(nullptr), _chunks(nullptr), _headers(nullptr)
, _secure(false)
{
#ifdef ESP32
threadLock = xSemaphoreCreateRecursiveMutex();
#endif
}
////////////////////////////////////////
AsyncHTTPSRequest::~AsyncHTTPSRequest()
{
if (_client)
_client->close(true);
SAFE_DELETE(_URL)
SAFE_DELETE(_headers)
SAFE_DELETE(_request)
SAFE_DELETE(_response)
SAFE_DELETE(_chunks)
SAFE_DELETE_ARRAY(_connectedHost)
#ifdef ESP32
// KH add
if (threadLock)
{
vSemaphoreDelete(threadLock);
}
#endif
}
////////////////////////////////////////
void AsyncHTTPSRequest::setDebug(bool debug)
{
if (_debug || debug)
{
_debug = true;
}
_debug = debug;
}
////////////////////////////////////////
bool AsyncHTTPSRequest::debug()
{
return (_debug);
}
////////////////////////////////////////
// KH Add for HTTPS
AsyncHTTPSRequest& AsyncHTTPSRequest::setSecure(bool secure)
{
_secure = secure;
return *this;
}
////////////////////////////////////////
AsyncHTTPSRequest& AsyncHTTPSRequest::addServerFingerprint(const uint8_t* fingerprint)
{
std::array<uint8_t, SHA1_SIZE> newFingerprint;
memcpy(newFingerprint.data(), fingerprint, SHA1_SIZE);
_secureServerFingerprints.push_back(newFingerprint);
return *this;
}
////////////////////////////////////////
bool AsyncHTTPSRequest::open(const char* method, const char* URL)
{
AHTTPS_LOGDEBUG3(F("open("), method, F(", url ="), URL);
if (_readyState != readyStateUnsent && _readyState != readyStateDone)
{
AHTTPS_LOGERROR(F("open: not ready"));
return false;
}
_requestStartTime = millis();
SAFE_DELETE(_URL)
SAFE_DELETE(_headers)
SAFE_DELETE(_request)
SAFE_DELETE(_response)
SAFE_DELETE(_chunks)
_URL = nullptr;
_headers = nullptr;
_response = nullptr;
_request = nullptr;
_chunks = nullptr;
_chunked = false;
_contentRead = 0;
_readyState = readyStateUnsent;
_requestReadyToSend = false;
if (strcmp(method, "GET") == 0)
{
_HTTPmethod = HTTPmethodGET;
}
else if (strcmp(method, "POST") == 0)
{
_HTTPmethod = HTTPmethodPOST;
}
else if (strcmp(method, "PUT") == 0)
{
_HTTPmethod = HTTPmethodPUT;
}
else if (strcmp(method, "PATCH") == 0)
{
_HTTPmethod = HTTPmethodPATCH;
}
else if (strcmp(method, "DELETE") == 0)
{
_HTTPmethod = HTTPmethodDELETE;
}
else if (strcmp(method, "HEAD") == 0)
{
_HTTPmethod = HTTPmethodHEAD;
}
else
{
AHTTPS_LOGERROR(F("open: Bad method"));
return false;
}
if (!_parseURL(URL))
{
AHTTPS_LOGERROR(F("open: error parsing URL"));
return false;
}
#if NOT_SEND_HEADER_AFTER_CONNECTED
if ( _client && _client->connected() )
{
if ( (strcmp(_URL->host, _connectedHost) == 0) && (_URL->port == _connectedPort) )
{
AHTTPS_LOGINFO(F("open: already connected"));
_lastActivity = millis();
_requestReadyToSend = true;
return _connect();
}
else
{
AHTTPS_LOGINFO(F("open: not connected: different host or port"));
return false;
}
}
#else
if ( _client && _client->connected() && (strcmp(_URL->host, _connectedHost) != 0 || _URL->port != _connectedPort))
{
AHTTPS_LOGERROR(F("open: not connected"));
return false;
}
#endif
char* hostName = new char[strlen(_URL->host) + 10];
if (hostName)
{
sprintf(hostName, "%s:%d", _URL->host, _URL->port);
_addHeader("host", hostName);
AHTTPS_LOGINFO1(F("open: connecting to hostname ="), hostName);
SAFE_DELETE_ARRAY(hostName)
_lastActivity = millis();
_requestReadyToSend = true;
return _connect();
}
else
{
AHTTPS_LOGERROR(F("open: error alloc"));
return false;
}
}
////////////////////////////////////////
void AsyncHTTPSRequest::onReadyStateChange(readyStateChangeCB cb, void* arg)
{
_readyStateChangeCB = cb;
_readyStateChangeCBarg = arg;
}
////////////////////////////////////////
void AsyncHTTPSRequest::setTimeout(int seconds)
{
_timeout = seconds;
}
////////////////////////////////////////
bool AsyncHTTPSRequest::send()
{
if (!_requestReadyToSend)
{
AHTTPS_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
MUTEX_LOCK(false)
if ( ! _buildRequest())
return false;
_send();
_AHTTPS_unlock;
return true;
}
////////////////////////////////////////
bool AsyncHTTPSRequest::send(const String& body)
{
if (!_requestReadyToSend)
{
AHTTPS_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
MUTEX_LOCK(false)
_addHeader("Content-Length", String(body.length()).c_str());
if ( ! _buildRequest())
{
_AHTTPS_unlock;
return false;
}
_request->write(body);
_send();
_AHTTPS_unlock;
return true;
}
////////////////////////////////////////
bool AsyncHTTPSRequest::send(const char* body)
{
if (!_requestReadyToSend)
{
AHTTPS_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
MUTEX_LOCK(false)
_addHeader("Content-Length", String(strlen(body)).c_str());
if ( ! _buildRequest())
{
_AHTTPS_unlock;
return false;
}
_request->write(body);
_send();
_AHTTPS_unlock;
return true;
}
////////////////////////////////////////
bool AsyncHTTPSRequest::send(const uint8_t* body, size_t len)
{
if (!_requestReadyToSend)
{
AHTTPS_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
MUTEX_LOCK(false)
_addHeader("Content-Length", String(len).c_str());
if ( ! _buildRequest())
{
_AHTTPS_unlock;
return false;
}
_request->write(body, len);
_send();
_AHTTPS_unlock;
return true;
}
////////////////////////////////////////
bool AsyncHTTPSRequest::send(xbuf* body, size_t len)
{
if (!_requestReadyToSend)
{
AHTTPS_LOGERROR(CANT_SEND_BAD_REQUEST);
return false;
}
MUTEX_LOCK(false)
_addHeader("Content-Length", String(len).c_str());
if ( ! _buildRequest())
{
_AHTTPS_unlock;
return false;
}
_request->write(body, len);
_send();
_AHTTPS_unlock;
return true;
}
////////////////////////////////////////
void AsyncHTTPSRequest::abort()
{
AHTTPS_LOGERROR(F("abort()"));
if (! _client)
{
return;
}
MUTEX_LOCK_NR
_client->abort();
_AHTTPS_unlock;
}
////////////////////////////////////////
reqStates AsyncHTTPSRequest::readyState()
{
return _readyState;
}
////////////////////////////////////////
int AsyncHTTPSRequest::responseHTTPcode()
{
return _HTTPcode;
}
////////////////////////////////////////
String AsyncHTTPSRequest::responseHTTPString()
{
switch (_HTTPcode)
{
case 0:
return F("OK");
case HTTPCODE_CONNECTION_REFUSED:
return F("CONNECTION_REFUSED");
case HTTPCODE_SEND_HEADER_FAILED:
return F("SEND_HEADER_FAILED");
case HTTPCODE_SEND_PAYLOAD_FAILED:
return F("SEND_PAYLOAD_FAILED");
case HTTPCODE_NOT_CONNECTED:
return F("NOT_CONNECTED");
case HTTPCODE_CONNECTION_LOST:
return F("CONNECTION_LOST");
case HTTPCODE_NO_STREAM:
return F("NO_STREAM");
case HTTPCODE_NO_HTTP_SERVER:
return F("NO_HTTP_SERVER");
case HTTPCODE_TOO_LESS_RAM:
return F("TOO_LESS_RAM");
case HTTPCODE_ENCODING:
return F("ENCODING");
case HTTPCODE_STREAM_WRITE:
return F("STREAM_WRITE");
case HTTPCODE_TIMEOUT:
return F("TIMEOUT");
// HTTP positive code
case 100:
return F("Continue");
case 101:
return F("Switching Protocols");
case 200:
return F("HTTP OK");
case 201:
return F("Created");
case 202:
return F("Accepted");
case 203:
return F("Non-Authoritative Information");
case 204:
return F("No Content");
case 205:
return F("Reset Content");
case 206:
return F("Partial Content");
case 300:
return F("Multiple Choices");
case 301:
return F("Moved Permanently");
case 302:
return F("Found");
case 303:
return F("See Other");
case 304:
return F("Not Modified");
case 305:
return F("Use Proxy");
case 307:
return F("Temporary Redirect");
case 400:
return F("Bad Request");
case 401:
return F("Unauthorized");
case 402:
return F("Payment Required");
case 403:
return F("Forbidden");
case 404:
return F("Not Found");
case 405:
return F("Method Not Allowed");
case 406:
return F("Not Acceptable");
case 407:
return F("Proxy Authentication Required");
case 408:
return F("Request Time-out");
case 409:
return F("Conflict");
case 410:
return F("Gone");
case 411:
return F("Length Required");
case 412:
return F("Precondition Failed");
case 413:
return F("Request Entity Too Large");