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 not read content-disposition from resposne header #67

Open
pkumar84 opened this Issue Jan 20, 2016 · 12 comments

Comments

Projects
None yet
10 participants
@pkumar84
Copy link

pkumar84 commented Jan 20, 2016

I am creating download url at frontend side and server send me data in response body and content-type, content-disposition in response header. i am able to read response.headers.get('content-type') but not response.headers.get('content-disposition'), is response.headers.get('content-disposition') does not supported ?

@cmloegcmluin

This comment has been minimized.

Copy link

cmloegcmluin commented Mar 8, 2016

We are experiencing a similar issue. The response object coming back from fetch is missing headers besides content-type. In our case we are looking for X-Vcap-Request-Id.

we're able to see a number of headers in the network tab of chrome's devtools, but the only one that is available via the headers through this lib is response.headers.get('content-type')

@malagant

This comment has been minimized.

Copy link

malagant commented Sep 21, 2016

Any news on this? I have the very same problem and I am getting nervous. ;)

@tw-360vier

This comment has been minimized.

Copy link

tw-360vier commented Sep 27, 2016

I'm having a similar problem: the only headers i can see are: 'cache-control', 'content-type' and 'expires'.
I can see more headers in chrome devtools, too. And i really need to read those hawk headers...

@tw-360vier

This comment has been minimized.

Copy link

tw-360vier commented Oct 7, 2016

Since this is an issue with the browser side implementation (https://github.com/github/fetch) of this package, doesn't this issue belong there?
Also, i think my problems are probably caused by some missing CORS settings:
github/fetch#399

@jch254

This comment has been minimized.

Copy link

jch254 commented Oct 18, 2016

Me too. Seeing the Content-Disposition header in Chrome devtools but response.headers.get('content-disposition') is null :s

@malagant

This comment has been minimized.

Copy link

malagant commented Oct 18, 2016

At least I don't believe that this is an issue of isomorpic-fetch oder fetch either.
We use a rails api backend and solved the issue with this in a cors initializer:

# Be sure to restart your server when you modify this file.

# Avoid CORS issues when API is called from the frontend app.
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.

# Read more: https://github.com/cyu/rack-cors

if Rails.env == 'development'
    Rails.application.config.middleware.insert_before 0, Rack::Cors do
      allow do
        origins 'localhost:10020'

        resource '*',
          headers: :any,
          methods: [:get, :post, :put, :patch, :delete, :options, :head],
          expose: [
            'X-Total', 
            'X-Total-Pages', 
            'X-Page', 
            'X-Per-Page', 
            'X-Next-Page', 
            'X-Prev-Page',
            'X-Offset',
            'X-Rdb-Lang'
          ]
      end
    end
end

As you can see, we are exposing explicitly needed headers. And so should you with content-disposition.
Although this is a rails example. You should be able to expose the headers in JavaScript also.

Hope this helps someone.

@jch254

This comment has been minimized.

Copy link

jch254 commented Oct 18, 2016

@malagant you're right! Even if the headers show in Chrome devtools they're not necessarily included in a CORS response. I explicitly exposed the Content-Disposition header server side and all worked. Cheers cheers!

@george-norris-salesforce

This comment has been minimized.

Copy link

george-norris-salesforce commented Nov 1, 2016

Using isomorphic-fetch in Node/Express to request images from third party API (thus can't control certain CORs settings). Is there a way to get a full set of headers from Fetch/third party API? Using Node Request exposes all headers, Fetch does not.

Only headers returned in Fetch are:
cache-control
expires
content-type
content-length

@JoshMcCullough

This comment has been minimized.

Copy link

JoshMcCullough commented Mar 7, 2017

No resolution to this yet?! :(

@sumlight

This comment has been minimized.

Copy link

sumlight commented Mar 22, 2017

I have same issue, can see 'X-Total-Count' in Chrome devtool, but there is no such key in fetch's response headers.

@Cherepanov6

This comment has been minimized.

Copy link

Cherepanov6 commented Dec 22, 2017

Add the "Access-Control-Expose-Headers" header to response from server. To read from javaScript "content-disposition" header add to response on server this Access-Control-Expose-Headers:Content-Disposition. Then this code will work: response.headers.get('content-disposition')

@wdamianw

This comment has been minimized.

Copy link

wdamianw commented Jun 25, 2018

In C# you could do so by writing:
result.Content.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
At least it worked for me finally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.