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

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

Open
analuciapaco opened this issue Nov 25, 2020 · 0 comments
Open

Comments

@analuciapaco
Copy link

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());

});
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant