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

Add Elasticsearch scan reader #802

Merged
merged 17 commits into from
Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Change HttpClient to support http post
  • Loading branch information
wuyunfeng committed Mar 25, 2019
commit d1627521931436a86ad2b1720ba93c04e647aa1b
10 changes: 10 additions & 0 deletions be/src/http/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ HttpClient::HttpClient() {

HttpClient::~HttpClient() {
if (_curl != nullptr) {
curl_slist header_list = nullptr;
curl_easy_getinfo(_curl, CURLOPT_HTTPHEADER, &header_list);
curl_easy_cleanup(_curl);
if(header_list != nullptr) {
curl_slist_free_all(header_list);
}
_curl = nullptr;
}
if(_header_list != nullptr) {
Expand All @@ -40,6 +45,11 @@ Status HttpClient::init(const std::string& url) {
return Status("fail to initalize curl");
}
} else {
curl_slist header_list = nullptr;
curl_easy_getinfo(_curl, CURLOPT_HTTPHEADER, &header_list);
if(slist != nullptr) {
curl_slist_free_all(header_list);
}
curl_easy_reset(_curl);
}

Expand Down
12 changes: 12 additions & 0 deletions be/test/http/http_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ TEST_F(HttpClientTest, post_normal) {
ASSERT_STREQ(response.c_str(), request_body.c_str());
}

TEST_F(HttpClientTest, post_normal) {
HttpClient client;
auto st = client.init("http://127.0.0.1:29386/simple_post");
ASSERT_TRUE(st.ok());
client.set_method(POST);
std::string response;
std::string request_body = "simple post body query";
st = client.execute_post_request(request_body, &response);
ASSERT_TRUE(st.ok());
ASSERT_EQ(response.length(), request_body.length());
}

}

int main(int argc, char* argv[]) {
Expand Down