Skip to content

Text/xml content type not treated as text on iOS #4514

@swishstache

Description

@swishstache

Issue
On iOS, when a http response is of the content type "text/xml", the result of the http.post method is a string representation of NSData rather than XML. On Android, the result is the expected XML of the response.

Impact
Response bodies cannot be parsed as XML.

Recreate
Using a url that responds with a content type of "text/xml", submit a request.

Example code

loginUser(): RxObservable<Response> {
    return http.post(url, body, options)
        .timeout(100000, new Error('Connection Timeout'))
        .map(res => res);
}
let res = loginEfxUser();
let result = res.text();

"result" is now a string representation of NSData (such as "<33336563 39643830 2d353236 642d3465 36322d38 6435652d 32393637 37663538 36303330>") rather than XML.

We've worked around this by changing "tns-core-modules/xhr/xhr.js" so that http/XMLHttpRequest.textTypes includes "text/xml" and tar-zip'ing the package locally.

This issue appears to have been similar: NativeScript/nativescript-angular#352

  • CLI: "tns --version" => 2.5.2
  • module: tns-core-modules@2.5.1
  • Runtime: "tns-ios": { "version": "3.1.0" }
  • Plugins
    "dependencies": {
    "@angular/common": "2.3.1",
    "@angular/compiler": "2.3.1",
    "@angular/core": "2.3.1",
    "@angular/forms": "2.3.1",
    "@angular/http": "2.3.1",
    "@angular/platform-browser": "2.3.1",
    "@angular/platform-browser-dynamic": "2.3.1",
    "@angular/router": "3.3.1",
    "events": "^1.1.1",
    "nativescript-adobe-marketing-cloud": "file:local_node_modules/nativescript-adobe-marketing-cloud-1.3.1.tgz",
    "nativescript-angular": "1.3.0",
    "nativescript-appversion": "~1.4.1",
    "nativescript-fingerprint-auth": "^4.0.0",
    "nativescript-loading-indicator": "^2.2.2",
    "nativescript-ngx-fonticon": "^2.1.2",
    "nativescript-secure-storage": "^2.1.0",
    "nativescript-telerik-ui": "1.5.1",
    "nativescript-theme-core": "1.0.2",
    "nativescript-unit-test-runner": "^0.3.4",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-rc.4",
    "timers": "^0.1.1",
    "tns-core-modules": "file:local_node_modules/tns-core-modules-2.5.1.tgz",
    "tns-platform-declarations": "^2.5.2",
    "xml2js": "^0.4.17"
    },
    "devDependencies": {
    "@types/xml2js": "^0.0.33",
    "@types/jasmine": "^2.5.47",
    "babel-traverse": "6.8.0",
    "babel-types": "6.8.1",
    "babylon": "6.8.0",
    "codelyzer": "0.0.28",
    "jasmine-core": "^2.5.2",
    "karma": "^1.6.0",
    "karma-jasmine": "^1.1.0",
    "karma-nativescript-launcher": "^0.4.0",
    "lazy": "1.0.11",
    "nativescript-dev-sass": "0.4.2",
    "nativescript-dev-typescript": "0.3.2",
    "tslint": "3.14.0",
    "typescript": "2.0.10",
    "zone.js": "0.7.2"
    },

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions