Domanda

Sto cercando di impostare il tipo di contenuto per le intestazioni Urlrequest su "Applicazione/JSON". Ecco il codice:

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

Ma come puoi vedere sul tipo di contenuto dello screenshot non è nelle intestazioni:

http://screencast.com/t/vhxhbsuofm

Ma è nell'organismo di richiesta:

http://screencast.com/t/irb16tao

Come farlo bene?

È stato utile?

Soluzione

È necessario utilizzare la classe UrlRequestHeader per impostare le intestazioni e spingerla. Vedi sotto per un semplice esempio,

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

Spero che questo abbia aiutato

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top