Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
Update: Fixed error that hasn't been supported earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodek committed Nov 10, 2016
1 parent e32f948 commit 4267425
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
11 changes: 10 additions & 1 deletion app.fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,15 @@ class SocketFetch extends ArcEventSource {
try {
this._processSocketMessage(readInfo.data);
} catch (e) {
console.error('Fix me please', e);
if (this.state === SocketFetch.STATUS ||
this.state === SocketFetch.HEADERS) {
// The response is totally wrong!
this._errorRequest({
'message': e.message || 'Unknown error occurred'
});
return;
}
console.error('Error occured reading part of the message', e);
}
chrome.sockets.tcp.setPaused(this._connection.socketId, false);
}
Expand Down Expand Up @@ -1519,6 +1527,7 @@ class SocketFetch extends ArcEventSource {
// Finishes the response with error message.
_errorRequest(opts) {
this.aborted = true;
this.state = SocketFetch.DONE;
var message;
if (opts.code && !opts.message) {
message = this.getCodeMessage(opts.code);
Expand Down
20 changes: 10 additions & 10 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ <h2>Log</h2>
demo.url = '';
demo.payload = '';
demo.headers = '';
demo.method = 'POST';

// demo.method = 'POST';
demo.method = 'GET';
demo.addEventListener('dom-change', function() {
// demo.url = 'https://chromerestclient.appspot.com/test?p=json';
// demo.url = 'http://localhost:8081/redirect';
Expand All @@ -133,8 +133,8 @@ <h2>Log</h2>
demo.url = 'http://localhost:8081/post-redirect';
// demo.url = 'http://192.168.1.25/';
demo.url = 'http://localhost:8081/ntlm';
demo.set('payload', '{"test":"request"}');
demo.set('method', 'POST');
// demo.set('payload', '{"test":"request"}');
// demo.set('method', 'POST');
demo.set('headers',
`Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate
Expand All @@ -149,12 +149,12 @@ <h2>Log</h2>
'headers': new Headers(headersToObject(demo.headers)),
'debug': true,
'timeout': 5000,
'auth': {
'uid': 'test',
'passwd': 'test',
'domain': 'workgroup',
'method': 'ntlm'
}
// 'auth': {
// 'uid': 'test',
// 'passwd': 'test',
// 'domain': 'workgroup',
// 'method': 'ntlm'
// }
};
if (demo.method === 'POST') {
init.body = demo.payload;
Expand Down

0 comments on commit 4267425

Please sign in to comment.