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

fix(subdomain-gw): curl on localhost (Option A: HTTP301+payload) #6982

Merged
merged 1 commit into from
Mar 13, 2020

Commits on Mar 13, 2020

  1. fix(gateway): curl without redirect on localhost

    When request is sent to http://localhost:8080/ipfs/$cid response has
    HTTP 301 status code and "Location" header with redirect destination at
    $cid.ipfs.localhost:8080
    
    Redirect is followed by browsersi, but not by commandline tools.
    Status 301 is ignored by curl in default mode: it will print response
    and won't follow redirect, user needs to add -L for that.
    
    To fix curl, we return correct payload in body of HTTP 301 response,
    but set Clear-Site-Data header to ensure Origin sandbox can't be abused.
    
    This requires a surgical workaround:
    If Location header is present in ResponseWriter's Header map,
    we ensure http.ServeContent() returns HTTP 301
    
    Context: #6982
    
    License: MIT
    Signed-off-by: Marcin Rataj <lidel@lidel.org>
    lidel committed Mar 13, 2020
    Configuration menu
    Copy the full SHA
    9fe44b7 View commit details
    Browse the repository at this point in the history