문제

I'm trying to set Content-Type for URLRequest headers to "application/json". Here is the code:

var request:URLRequest = new URLRequest("http://localhost");
request.contentType =  "application/json; charset=UTF-8";

But as you can see on screenshot Content-Type is not in headers:

http://screencast.com/t/vHxHbSUOFM

But it's in request body:

http://screencast.com/t/irB16taO

How to make it right?

도움이 되었습니까?

해결책

You need to use the URLRequestHeader class to set headers and push it. See below for a simple example,

var hdr:URLRequestHeader = new URLRequestHeader("Content-type", "application/json");
var request:URLRequest = new URLRequest("http://localhost");
request.requestHeaders.push(hdr);

Hope this helped

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top