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

Can't set Host header via req_headers() #564

Open
i2z1 opened this issue Oct 14, 2024 · 1 comment
Open

Can't set Host header via req_headers() #564

i2z1 opened this issue Oct 14, 2024 · 1 comment

Comments

@i2z1
Copy link

i2z1 commented Oct 14, 2024

I am trying to upload file with httr2 to S3 with custom endpoint (so have problems using aws.s3 package, so making it with httr2). While constructing request I found that cant overide Host header with req_headers() function, it always matches to base url, provided with request() function.

  
  resp <- request(s3baseurl) %>% 
    req_method("PUT") %>% 
    req_body_file(path = file) %>% 
    req_headers(
      "Host" = paste0(bucket, ".storage.example.com"),
      "Date" = dateValue,
      "ContentType" = contentType,
      "Authorization" = paste0("AWS ", s3_key_id, ":", signature)) %>% 
    req_dry_run()

Output:

PUT / HTTP/1.1
Host: example.com
User-Agent: httr2/1.0.5 r-curl/5.2.3 libcurl/8.10.1
Accept: */*
Accept-Encoding: deflate, gzip, br, zstd
Date: Mon, 14 Oct 2024 17:24:29 +0300
ContentType: text/xml
Authorization: AWS YCAJEsP-XW0vHQNghKS2t68GK:XZHHgch9Qbm1u6pVsQv8HpjtPMI=
Content-Length: 38922

38922 bytes of binary data

Is there are some way to change Host header with httr2?

@hadley
Copy link
Member

hadley commented Oct 16, 2024

It looks like this is an artifact of the way that req_dry_run() works; I think it should actually be setting the host header for real requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants