Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jQuery] streaming, opera breaks on junk split + FIX #625

Closed
PavelR577 opened this issue Sep 17, 2012 · 2 comments
Closed

[jQuery] streaming, opera breaks on junk split + FIX #625

PavelR577 opened this issue Sep 17, 2012 · 2 comments

Comments

@PavelR577
Copy link

when junk is getting broadcasted in parts opera will fail to establish connection.

Here is the fixed code:

in function _executeRequest(request)

if (!_response.junkFull && (text.indexOf("<!-- Welcome to the Atmosphere Framework.") == -1 || text.indexOf("<!-- EOD -->") == -1)) {
    if (!jQuery.browser.opera)
        return;
} else
    _response.junkFull = true;

and in the bottom:

 if (jQuery.browser.opera) {
    jQuery.atmosphere.iterate(function() {
        if (ajaxRequest.responseText.length > rq.lastIndex) {
            try {
                _response.status = ajaxRequest.status;
                _response.headers = parseHeaders(ajaxRequest.getAllResponseHeaders());

                // HOTFIX for firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=608735
                if (_request.readResponsesHeaders && _request.headers) {
                    jQuery.each(_request.headers, function(name) {
                        var v = ajaxRequest.getResponseHeader(name);
                        if (v) {
                            _response.headers[name] = v;
                        }
                    });
                }
            }
            catch(e) {
                _response.status = 404;
            }
//todo: fix for junk comming in parts in opera
            if (!_response.junkFull) {
                var endOfJunk = "<!-- EOD -->";
                var endOfJunkLength = endOfJunk.length;
                var junkEnd = ajaxRequest.responseText.indexOf(endOfJunk) + endOfJunkLength;
                rq.lastIndex = junkEnd; //skip to end of junk
                _response.junkFull = true;
            } else {
                //any message from the server will reset the last ping time
                rq.lastPingTime = (new Date()).getTime();
                _response.state = "messageReceived";
                _response.responseBody = ajaxRequest.responseText.substring(rq.lastIndex);
                rq.lastIndex = ajaxRequest.responseText.length;

                _invokeCallback();
                if ((rq.transport == 'streaming') && (ajaxRequest.responseText.length > rq.maxStreamingLength)) {
                    // Close and reopen connection on large data received
                    ajaxRequest.abort();
                    _doRequest(ajaxRequest, rq, true);
                }
            }
        }
    }, 0);
}
@jfarcand
Copy link
Member

Salut, it is hard to find what you really changed. I strongly recommend you do a pull request if you can, or at least attach a git diff of the atmosphere.js file. Thanks!!!

@jfarcand
Copy link
Member

Patch applied, thanks!

jfarcand added a commit that referenced this issue Sep 18, 2012
jfarcand added a commit that referenced this issue Sep 18, 2012
jfarcand added a commit that referenced this issue Jan 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants