Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp_http_client: add head method support #2093

Closed
wants to merge 1 commit into from

Conversation

jkoelker
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Jun 23, 2018

CLA assistant check
All committers have signed the CLA.

@ghost
Copy link

ghost commented Jun 25, 2018

I think it would be more helpful to add some description on this PR.

@@ -690,6 +691,11 @@ static int esp_http_client_get_data(esp_http_client_handle_t client)
if (client->state < HTTP_STATE_RES_COMPLETE_HEADER) {
return ESP_FAIL;
}

if (client->connection_info.method == HTTP_METHOD_HEAD) {
return 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 means ESP_OK? It would be better to use more meaningful definition instead of 0.

Copy link
Contributor Author

@jkoelker jkoelker Jun 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it means 0 bytes read. The return of the function is the number of bytes read. The above ESP_FAIL return seems to rely on the fact that currently ESP_FAIL is #define'd to -1. I wavered in putting the HEAD check below in esp_http_client_perform and just skipping looking at the body at all, but then the state check above would need to move as well, and the correct data length for a HEAD request is 0 since the RFC states that it "must not return a message-body in the response", so the esp_http_client_get_data seemed more appropriate.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining your intention. This function's return type is int. If a function's return type is esp_err_t then we should consider using ESP_OK.

esp_http_client_get_content_length(client));
} else {
ESP_LOGE(TAG, "HTTP HEAD request failed: %s", esp_err_to_name(err));
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good test case!

@igrr igrr requested a review from tuanpmt July 23, 2018 21:47
@tuanpmt
Copy link
Contributor

tuanpmt commented Jul 24, 2018

Thanks for the useful method,

LGTM

@igrr igrr added the Status: Pending blocked by some other factor label Jul 31, 2018
igrr pushed a commit that referenced this pull request Aug 9, 2018
@igrr
Copy link
Member

igrr commented Aug 9, 2018

Cherry-picked as 483c3d7, thanks @jkoelker!

@igrr igrr closed this Aug 9, 2018
@igrr igrr removed the Status: Pending blocked by some other factor label Aug 9, 2018
catalinio pushed a commit to catalinio/pycom-esp-idf that referenced this pull request Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants