Skip to content

Commit

Permalink
Merge pull request #188 from noh4hss/setheader
Browse files Browse the repository at this point in the history
fix SetHeader() implementation
  • Loading branch information
whoshuu committed Oct 27, 2017
2 parents 749a098 + 942cd99 commit 9018cdf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cpr/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,16 @@ void Session::Impl::SetHeader(const Header& header) {
} else {
header_string += ": " + item->second;
}
chunk = curl_slist_append(chunk, header_string.data());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
curl_->chunk = chunk;

auto temp = curl_slist_append(chunk, header_string.data());
if (temp) {
chunk = temp;
}
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);

curl_slist_free_all(curl_->chunk);
curl_->chunk = chunk;
}
}

Expand Down

0 comments on commit 9018cdf

Please sign in to comment.