|
2 | 2 | * HTTP implementation |
3 | 3 | */ |
4 | 4 |
|
| 5 | +#define VERBOSE_HTTP 1 |
| 6 | +#define VERBOSE_PROTOCOL 1 |
| 7 | + |
5 | 8 | #include <cstring> |
6 | 9 |
|
7 | 10 | #include "HTTP.h" |
@@ -440,7 +443,7 @@ bool NetworkProtocolHTTP::status_file(NetworkStatus *status) |
440 | 443 | { |
441 | 444 | case DATA: |
442 | 445 | { |
443 | | - if (!fromInterrupt && resultCode == 0) |
| 446 | + if (!fromInterrupt && resultCode == 0 && aux1_open != OPEN_MODE_HTTP_PUT_H) |
444 | 447 | { |
445 | 448 | #ifdef VERBOSE_PROTOCOL |
446 | 449 | Debug_printf("calling http_transaction\r\n"); |
@@ -558,7 +561,7 @@ bool NetworkProtocolHTTP::close_file_handle() |
558 | 561 |
|
559 | 562 | if (client != nullptr) |
560 | 563 | { |
561 | | - if (httpOpenMode == PUT) |
| 564 | + if (httpOpenMode == PUT || aux1_open == OPEN_MODE_HTTP_PUT_H) |
562 | 565 | http_transaction(); |
563 | 566 | client->close(); |
564 | 567 | fserror_to_error(); |
@@ -675,14 +678,14 @@ bool NetworkProtocolHTTP::write_file_handle_send_post_data(uint8_t *buf, unsigne |
675 | 678 |
|
676 | 679 | bool NetworkProtocolHTTP::write_file_handle_data(uint8_t *buf, unsigned short len) |
677 | 680 | { |
678 | | - if (httpOpenMode != PUT) |
| 681 | + if (httpOpenMode == PUT || aux1_open == OPEN_MODE_HTTP_PUT_H) |
679 | 682 | { |
680 | | - error = NETWORK_ERROR_INVALID_COMMAND; |
681 | | - return true; |
| 683 | + postData += std::string((char *)buf, len); |
| 684 | + return false; // come back here later. |
682 | 685 | } |
683 | 686 |
|
684 | | - postData += std::string((char *)buf, len); |
685 | | - return false; // come back here later. |
| 687 | + error = NETWORK_ERROR_INVALID_COMMAND; |
| 688 | + return true; |
686 | 689 | } |
687 | 690 |
|
688 | 691 | bool NetworkProtocolHTTP::stat() |
@@ -738,7 +741,7 @@ void NetworkProtocolHTTP::http_transaction() |
738 | 741 | resultCode = client->GET(); |
739 | 742 | break; |
740 | 743 | case POST: |
741 | | - if (aux1_open == 14) |
| 744 | + if (aux1_open == OPEN_MODE_HTTP_PUT_H) |
742 | 745 | resultCode = client->PUT(postData.c_str(), postData.size()); |
743 | 746 | else |
744 | 747 | resultCode = client->POST(postData.c_str(), postData.size()); |
@@ -766,6 +769,9 @@ void NetworkProtocolHTTP::http_transaction() |
766 | 769 |
|
767 | 770 | fserror_to_error(); |
768 | 771 | fileSize = bodySize = client->available(); |
| 772 | +#ifdef VERBOSE_PROTOCOL |
| 773 | + Debug_printf("NetworkProtocolHTTP::http_transaction() done, resultCode=%d, fileSize=%u\r\n", resultCode, fileSize); |
| 774 | +#endif |
769 | 775 | } |
770 | 776 |
|
771 | 777 | bool NetworkProtocolHTTP::rename(PeoplesUrlParser *url, cmdFrame_t *cmdFrame) |
|
0 commit comments