Skip to content

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

@i2z1

Description

@i2z1

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions