HttpRequest (dart : html)로 POST 요청을 시도하여 기본 인증으로 보안 된 나머지 서비스를 호출합니다. 인증 헤더없이 : DART HttpRequest가 CORS OPTIONS 요청에 대한 인증 헤더를 제공하지 않습니다.
HttpRequest request = new HttpRequest(); // create a new XHR
var url = "http://localhost:8082/xyz";
request.open("POST", url, async: false); // POST the data to the server
String username = "foo";
String password = "bar";
final auth = CryptoUtils.bytesToBase64(UTF8.encode("$username:$password"));
request.setRequestHeader('authorization',"Basic $auth");
request.setRequestHeader('content-type',"application/json");
request.setRequestHeader("accept", "application/json");
String jsonData = '{"language":"dart"}'; // etc...
request.send(jsonData); //exception 401 Unauthorized
요청 헤더 :
수락 : */*
수락 - 인코딩 : gzip을, 폐, SDCH
수락 - 언어 : EN-US, 욕실, Q = 0.8
액세스 제어 요청 헤더 : authorization, content-type, accept
액세스 제어 요청 방법 : POST
012 3,516,캐시 제어 : 최대 연령 = 0
연결 : 연결 유지
호스트 : 로컬 호스트 : 8082
원산지 : http://localhost:63342
리퍼러 : http://localhost:63342/dart_client/test/all_test.html
사용자 에이전트 : 모질라/5.0 (매킨토시; 게코 같은 인텔 맥 OS X 10_9_5) AppleWebKit/537.36 (KHTML) 크롬/38.0.2125.0 (다트) 사파리/537.36Reponse 헤더 :
콘텐츠 길이 : 0
날짜 : 2015년 (월) 2월 2일 그리니치 표준시 23시 33분 58초
서버 : 부두 (9.2.7.v20150116)
WWW 인증 : 기본 영역 = "xyzrealm"
OPTIONS 호출에 인증 헤더를 제공하는 방법이 있습니까?
어떤 제안이 좋을 것입니다. 감사합니다
감사합니다. 당신 말이 맞았어요, OPTIONS 요청은 브라우저에 의해 만들어졌습니다. 프리 플라이트 요청을 가능하게하기 위해, 나는 Jetty Server를위한 새로운 SecurityHandler를 만들어야했다. 예 : [link] (https://code.launchpad.net/~nwilliams/akiban-server/cors-preflight-no-auth/+merge/161690) –