Skip to content

Commit 7a5da60

Browse files
Merge pull request #256 from datadog-labs/fix/ddsql-user-agent-header
fix(client): set User-Agent header in raw HTTP helpers
2 parents 4a4892b + 81bca5e commit 7a5da60

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/client.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ static UNSTABLE_OPS: &[&str] = &[
220220
// Auth type detection
221221
// ---------------------------------------------------------------------------
222222

223+
use crate::useragent;
224+
223225
#[allow(dead_code)]
224226
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
225227
pub enum AuthType {
@@ -506,7 +508,11 @@ pub async fn raw_get(
506508
req = req.query(query);
507509
}
508510

509-
let resp = req.header("Accept", "application/json").send().await?;
511+
let resp = req
512+
.header("Accept", "application/json")
513+
.header("User-Agent", useragent::get())
514+
.send()
515+
.await?;
510516
if !resp.status().is_success() {
511517
let status = resp.status();
512518
let body = resp.text().await.unwrap_or_default();
@@ -539,6 +545,7 @@ pub async fn raw_patch(
539545
let resp = req
540546
.header("Content-Type", "application/json")
541547
.header("Accept", "application/json")
548+
.header("User-Agent", useragent::get())
542549
.json(&body)
543550
.send()
544551
.await?;
@@ -574,6 +581,7 @@ pub async fn raw_post(
574581
let resp = req
575582
.header("Content-Type", "application/json")
576583
.header("Accept", "application/json")
584+
.header("User-Agent", useragent::get())
577585
.json(&body)
578586
.send()
579587
.await?;

0 commit comments

Comments
 (0)