Skip to content

Commit

Permalink
fix(databend sink): use get for page request (vectordotdev#17373)
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc authored May 18, 2023
1 parent ae656c7 commit c7d7cf8
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/sinks/databend/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,8 @@ impl DatabendAPIClient {

async fn do_request(
&self,
url: String,
req: Option<DatabendHttpRequest>,
mut request: Request<Body>,
) -> Result<DatabendHttpResponse, DatabendError> {
let body = match req {
Some(r) => {
let body = serde_json::to_vec(&r)?;
Body::from(body)
}
None => Body::empty(),
};
let mut request = Request::post(url)
.header("Content-Type", "application/json")
.body(body)?;
if let Some(a) = &self.auth {
a.apply(&mut request);
}
Expand Down Expand Up @@ -163,15 +152,21 @@ impl DatabendAPIClient {
next_uri: String,
) -> Result<DatabendHttpResponse, DatabendError> {
let endpoint = self.get_page_endpoint(&next_uri)?;
self.do_request(endpoint, None).await
let request = Request::get(endpoint)
.header("Content-Type", "application/json")
.body(Body::empty())?;
self.do_request(request).await
}

pub(super) async fn query(
&self,
req: DatabendHttpRequest,
) -> Result<DatabendHttpResponse, DatabendError> {
let endpoint = self.get_query_endpoint()?;
let resp = self.do_request(endpoint, Some(req)).await?;
let request = Request::post(endpoint)
.header("Content-Type", "application/json")
.body(Body::from(serde_json::to_vec(&req)?))?;
let resp = self.do_request(request).await?;
match resp.next_uri {
None => Ok(resp),
Some(_) => {
Expand Down

0 comments on commit c7d7cf8

Please sign in to comment.