Git Product home page Git Product logo

Comments (5)

dicej avatar dicej commented on June 11, 2024 1

@lann I suspect this is where the problem is:

let host = format!("{}:{}", uri.host().unwrap(), uri.port().unwrap());
let headers = request.request.headers_mut();
headers.insert(HOST, HeaderValue::from_str(&host)?);
. Should we instead check for an existing "host" header and only set one if none already exists?

from spin.

lann avatar lann commented on June 11, 2024

I'm not sure where this behavior is coming from but in general it should be fine to include a default port number in an http host header.

If you manually set the host header on the request with just the hostname does it get replaced?

from spin.

seungjin avatar seungjin commented on June 11, 2024

If I force to add my own host header value with this: .header("Host", "seungjin.s3.amazonaws.com"),
I got a following message from Amzaon.
It is not overwriting but sending duplicated host header value:

<?xml version="1.0" encoding="UTF-8"?><Error><Code>DuplicateHeaderName</Code><Message>Your request contains duplicate headers.</Message>

from spin.

seungjin avatar seungjin commented on June 11, 2024

Okay. In this case, I am signing its request with the Host header value. Having a port or not is a BIG difference. The HTTP spec says it is okay to have it but also okay not to have it. But that's probably an old standard nobody needed to think about when signing a request with the hostname.

I sign the request with just the hostname (without the port), but AWS is using its host with the port because that's what AWS is getting. So the verification never happens. (Spin ships with a port, but curl and my Rust code with reqwest do not ship it.) To solve this for now (temporarily...), I also signed with the port number (forcefully adding {host}:{port}) and sent it to AWS. Of course, verification passed, and my image was up online with the trick.

The AWS API is a simpler case because my target is only one (AWS). But when I deal with Mastodon, it is not that simple. Some webservers (proxy, nginx, caddy, apache...) pass the port, and some don't. That's a configuration matter.

Anyway, I found a way I can work around it, but I don't think it is a permanent solution. Based on my search, Go/Java SDK developers have encountered similar cases.

I will get back and bash later when this issue becomes more critical. :-) Please don't close it until we clearly know what's going on. :-)

from spin.

lann avatar lann commented on June 11, 2024

Thanks for the update.

It is not overwriting but sending duplicated host header value:

This I think may be a bug, but will require some research to understand why its happening and how best to fix it.

from spin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.