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

storage: refused to set unsafe header "user-agent", "content-length" #73

Closed
johnpryan opened this issue Jun 5, 2019 · 3 comments
Closed

Comments

@johnpryan
Copy link

using the StorageApi client with a package:http BrowserClient can result in unsafe headers like "user-agent" and "content-length" getting set. XHRs aren't allowed to set these headers (ref)

Steps to reproduce:

  1. clone https://github.com/johnpryan/dart_sdk_archive
  2. run pub global activate webdev && webdev serve
  3. open http://localhost:8080
  4. open dev tools
  5. observe console warnings
@StorminGorman
Copy link

StorminGorman commented Aug 9, 2019

I found that this bug resides within https://github.com/dart-lang/discoveryapis_commons/blob/master/lib/src/clients.dart

So, this issue probably needs to move over to https://github.com/dart-lang/discoveryapis_commons .

        headers = {
          'user-agent': _userAgent,
          'content-type': CONTENT_TYPE_JSON_UTF8,
          'content-length': '$length',
        };

The offending code in this case: https://github.com/dart-lang/discoveryapis_commons/blob/53552b470e5827fb1cd5ceaec4b4253b477cbe43/lib/src/clients.dart#L203

I'm sure this works great for non-web clients. I guess a PR would be needed to pass in a boolean or have a new subclass that gets instantiated in the case of the request coming from a web client in order to drop the flags.

@jonasfj
Copy link
Member

jonasfj commented Aug 12, 2019

@StorminGorman, nice catch, I filed dart-archive/discoveryapis_commons#30

@jonasfj
Copy link
Member

jonasfj commented Sep 2, 2019

Fixed in _discoveryapis_commons version 0.1.8+2.

If you do a pub upgrade it should get into your project.

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

No branches or pull requests

3 participants