-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
XMLHttpRequest (HttpRequest) does not append request headers properly. #4595
Comments
I tested this, and Dartium is not setting the header. When I compile this to JavaScript, I see the header. #import('dart:html'); void main() { Dartium: no X-Awesome dart2js: yes X-Awesome See screenshots Attachments: Added Area-Dartium, Triaged labels. |
This comment was originally written by [email protected] Do you think this fix will make it into M1? |
Not sure yet, waiting for an engineer to check it out. |
This comment was originally written by [email protected] Pavel, please, may you have a look? Set owner to [email protected]. |
This comment was originally written by [email protected] Seth, there are two requests for xhrheaders.dart on the screenshot. The first one is resource request from html parser, and the second one is xhr from the script. Only xhr should have X-Awesome header. As for original issue, it looks like CORS preflight request (note that the method is "OPTIONS", not "POST"). Preflight request should be followed by a POST request that will have all the headers set. Added Invalid label. |
Thank you for looking into this. |
This issue was originally filed by [email protected]
Dart SDK 10595
Can't append request headers:
Produces: Access-Control-Request-Headers: origin, content-type, accept, x-couchdb-www-authenticate????
void processLogin() {
String url = "${couchdb}/_session";
String data = "name=${getUsername()}&password=${getPassword()}";
XMLHttpRequest request = new XMLHttpRequest();
request.on.loadEnd.add((XMLHttpRequestProgressEvent e) => _onLoadEnd(request));
request.open("POST", url, async : true);
request.setRequestHeader("X-CouchDB-WWW-Authenticate", "Cookie");
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.setRequestHeader("Accept", "application/json");
request.send(data);
}
Looks like:
OPTIONS /couchdb/_session HTTP/1.1
Host: 127.0.0.1
Connection: keep-alive
Access-Control-Request-Method: POST
Origin: http://127.0.0.1:3030
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.6 (KHTML, like Gecko) Chrome/23.0.1234.0 (Dart) Safari/537.6
Access-Control-Request-Headers: origin, content-type, accept, x-couchdb-www-authenticate
Accept: /
Referer: http://127.0.0.1:3030/Users/branflake2267/git/dart-examples/examples/DartExamples/DemoCouchDb/DemoCouchDb.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
https://groups.google.com/a/dartlang.org/d/topic/misc/MxQPRyKJxMU/discussion
The text was updated successfully, but these errors were encountered: