mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
http for android header values fixed and test added
This commit is contained in:
@ -340,6 +340,29 @@ export var test_request_contentSentAndReceivedProperly = function (done) {
|
||||
});
|
||||
};
|
||||
|
||||
export var test_request_NonStringHeadersSentAndReceivedProperly = function (done) {
|
||||
var result;
|
||||
|
||||
var postData = "MyVariableOne=ValueOne&MyVariableTwo=ValueTwo";
|
||||
|
||||
http.request({
|
||||
url: "https://httpbin.org/post", method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded", "Content-Length": postData.length },
|
||||
content: postData
|
||||
}).then(function (response) {
|
||||
result = response.content.toJSON();
|
||||
try {
|
||||
TKUnit.assert(result["form"]["MyVariableOne"] === "ValueOne" && result["form"]["MyVariableTwo"] === "ValueTwo", "Content not sent/received properly!");
|
||||
done(null);
|
||||
}
|
||||
catch (err) {
|
||||
done(err);
|
||||
}
|
||||
}, function (e) {
|
||||
done(e);
|
||||
});
|
||||
};
|
||||
|
||||
export var test_request_jsonAsContentSentAndReceivedProperly = function (done) {
|
||||
var result;
|
||||
|
||||
|
@ -85,7 +85,7 @@ function buildJavaOptions(options: http.HttpRequestOptions) {
|
||||
var pair = com.tns.Async.Http.KeyValuePair;
|
||||
|
||||
for (var key in options.headers) {
|
||||
arrayList.add(new pair(key, options.headers[key]));
|
||||
arrayList.add(new pair(key, options.headers[key] + ""));
|
||||
}
|
||||
|
||||
javaOptions.headers = arrayList;
|
||||
|
Reference in New Issue
Block a user