Skip to content

Commit

Permalink
Merge pull request #8 from ry023/readheader_evenif_4xx
Browse files Browse the repository at this point in the history
Call header_handler even if server returned 4xx response
  • Loading branch information
pyama86 authored Mar 1, 2019
2 parents 93f8304 + 57c9504 commit 074b2ec
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions stns.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ static CURLcode inner_http_request(stns_conf_t *c, char *path, stns_response_t *
curl_easy_setopt(curl, CURLOPT_WRITEDATA, res);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, c);
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);

if (c->tls_cert != NULL && c->tls_key != NULL) {
curl_easy_setopt(curl, CURLOPT_SSLCERT, c->tls_cert);
Expand All @@ -289,13 +288,14 @@ static CURLcode inner_http_request(stns_conf_t *c, char *path, stns_response_t *

result = curl_easy_perform(curl);

if (result != CURLE_OK) {
long code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
if (code >= 400) {
syslog(LOG_ERR, "%s(stns)[L%d] http request failed: %s", __func__, __LINE__, curl_easy_strerror(result));
if (result == CURLE_HTTP_RETURNED_ERROR) {
long code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
res->status_code = code;
}
res->data = NULL;
res->size = 0;
res->status_code = code;
result = CURLE_HTTP_RETURNED_ERROR;
}

free(auth);
Expand Down

0 comments on commit 074b2ec

Please sign in to comment.