mirror of
				https://github.com/esphome/esphome.git
				synced 2025-11-03 16:41:50 +00:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			power-supp
			...
			jesserockz
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					b5b4047241 | ||
| 
						 | 
					ddd5e345ac | ||
| 
						 | 
					c354afda17 | 
@@ -86,6 +86,8 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
 | 
				
			|||||||
    return nullptr;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ESP_LOGV(TAG, "HTTP Request started: %s", url.c_str());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (body_len > 0) {
 | 
					  if (body_len > 0) {
 | 
				
			||||||
    int write_left = body_len;
 | 
					    int write_left = body_len;
 | 
				
			||||||
    int write_index = 0;
 | 
					    int write_index = 0;
 | 
				
			||||||
@@ -108,10 +110,26 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
 | 
				
			|||||||
    return nullptr;
 | 
					    return nullptr;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ESP_LOGV(TAG, "HTTP Request body written: %d", body_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  container->content_length = esp_http_client_fetch_headers(client);
 | 
					  container->content_length = esp_http_client_fetch_headers(client);
 | 
				
			||||||
 | 
					  if (esp_http_client_is_chunked_response(client)) {
 | 
				
			||||||
 | 
					    ESP_LOGV(TAG, "HTTP Response is chunked");
 | 
				
			||||||
 | 
					    int length = 0;
 | 
				
			||||||
 | 
					    err = esp_http_client_get_chunk_length(client, &length);
 | 
				
			||||||
 | 
					    if (err != ESP_OK) {
 | 
				
			||||||
 | 
					      this->status_momentary_error("failed", 1000);
 | 
				
			||||||
 | 
					      ESP_LOGE(TAG, "Failed to get chunk length: %s", esp_err_to_name(err));
 | 
				
			||||||
 | 
					      esp_http_client_cleanup(client);
 | 
				
			||||||
 | 
					      return nullptr;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    container->content_length = length;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  const auto status_code = esp_http_client_get_status_code(client);
 | 
					  const auto status_code = esp_http_client_get_status_code(client);
 | 
				
			||||||
  container->status_code = status_code;
 | 
					  container->status_code = status_code;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ESP_LOGD(TAG, "Status %d", status_code);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (status_code < 200 || status_code >= 300) {
 | 
					  if (status_code < 200 || status_code >= 300) {
 | 
				
			||||||
    ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url.c_str(), status_code);
 | 
					    ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url.c_str(), status_code);
 | 
				
			||||||
    this->status_momentary_error("failed", 1000);
 | 
					    this->status_momentary_error("failed", 1000);
 | 
				
			||||||
@@ -147,6 +165,8 @@ void HttpContainerIDF::end() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  esp_http_client_close(this->client_);
 | 
					  esp_http_client_close(this->client_);
 | 
				
			||||||
  esp_http_client_cleanup(this->client_);
 | 
					  esp_http_client_cleanup(this->client_);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  ESP_LOGV(TAG, "HTTP Request ended: %d", this->status_code);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}  // namespace http_request
 | 
					}  // namespace http_request
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user