Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Error firefox IPV6 VUE.JS vue-resource.common.js XMLHttpRequest #749

@analuciapaco

Description

@analuciapaco

Error firefox IPV6 VUE.JS vue-resource.common.js XMLHttpRequest

Hi!. I ask that the error that occurs only in the firefox browser with IPV6 protocol be resolved. The error occurs: Not caught (in promise) DOMException: The URI is malformed. such problem occurs when entering a URL with the IPV6 protocol for example http: // [:: 1]: 8080 / rest / app

I noticed that the error is on the line: xhr.open (request.method, request.getUrl (), true);
I found that the solution to this problem is to change the line mentioned by the line below: xhr.open (request.method, request.url, true);
So that it is solved and works in all browsers (I only tested firefox, google and opera).

vue-resource v1.0.3 and also in version v1.5.1

Code below:

function xhrClient (request) {
return new PromiseObj(function (resolve) {

var xhr = new XMLHttpRequest(),
    handler = function (event) {

    var response = request.respondWith('response' in xhr ? xhr.response : xhr.responseText, {
        status: xhr.status === 1223 ? 204 : xhr.status, // IE9 status bug
        statusText: xhr.status === 1223 ? 'No Content' : trim(xhr.statusText)
    });

    each(trim(xhr.getAllResponseHeaders()).split('\n'), function (row) {
        response.headers.append(row.slice(0, row.indexOf(':')), row.slice(row.indexOf(':') + 1));
    });

    resolve(response);
};

request.abort = function () {
    return xhr.abort();
};

if (request.progress) {
    if (request.method === 'GET') {
        xhr.addEventListener('progress', request.progress);
    } else if (/^(POST|PUT)$/i.test(request.method)) {
        xhr.upload.addEventListener('progress', request.progress);
    }
}

xhr.open(request.method,request.getUrl(), true);

if ('responseType' in xhr) {
    xhr.responseType = 'blob';
}

if (request.credentials === true) {
    xhr.withCredentials = true;
}

request.headers.forEach(function (value, name) {
    xhr.setRequestHeader(name, value);
});

xhr.timeout = 0;
xhr.onload = handler;
xhr.onerror = handler;
xhr.send(request.getBody());

});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions