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

Commit

Permalink
[CI] Automated merge stage->master
Browse files Browse the repository at this point in the history
  • Loading branch information
arcauto committed Nov 10, 2016
2 parents ce7650d + f663f53 commit 0209a61
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 20 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
<a name="1.0.69"></a>
## [1.0.69](https://github.com/advanced-rest-client/socket-fetch/compare/1.0.66...v1.0.69) (2016-11-10)


### Fix

* Fixed issue #15 - upodated parsers to adjust number of consumed characters to the real value of new lines ([331261edbc9afb636d13bc8b67d6338c688362eb](https://github.com/advanced-rest-client/socket-fetch/commit/331261edbc9afb636d13bc8b67d6338c688362eb)), closes [#15](https://github.com/advanced-rest-client/socket-fetch/issues/15)
* Fixed issue #16 - Now calling error will call promise's reject function ([e32f948a77534523258e7038f57a430ae1f89f26](https://github.com/advanced-rest-client/socket-fetch/commit/e32f948a77534523258e7038f57a430ae1f89f26)), closes [#16](https://github.com/advanced-rest-client/socket-fetch/issues/16)
* Fixed variable name for socet sent info ([ee3248349bad1d0cd6de729fd0d13992474c5b55](https://github.com/advanced-rest-client/socket-fetch/commit/ee3248349bad1d0cd6de729fd0d13992474c5b55))
* Fixes #15 and #17 - new line as "10" ASCII only and status message error ([8f4652ef0214ba411718a182b02c037b3ae4ad54](https://github.com/advanced-rest-client/socket-fetch/commit/8f4652ef0214ba411718a182b02c037b3ae4ad54)), closes [#15](https://github.com/advanced-rest-client/socket-fetch/issues/15) [#17](https://github.com/advanced-rest-client/socket-fetch/issues/17)

### Update

* Fixed error that hasn't been supported earlier. ([4267425932e508d3727afb73d07017b22a63ab7d](https://github.com/advanced-rest-client/socket-fetch/commit/4267425932e508d3727afb73d07017b22a63ab7d))



<a name="1.0.68"></a>
## [1.0.68](https://github.com/advanced-rest-client/socket-fetch/compare/1.0.66...v1.0.68) (2016-10-20)

Expand Down
47 changes: 39 additions & 8 deletions app.fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ class SocketFetch extends ArcEventSource {
this._connection.port);
this._readyState = 1;
this._onConnected();
}).catch((cause) => {
})
.catch((cause) => {
if (this.redirects) {
// There were a redirects so it has something to display.
// Don't just throw an error, construct a response that is errored.
Expand Down Expand Up @@ -1048,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 @@ -1122,8 +1131,18 @@ class SocketFetch extends ArcEventSource {
}
this.log('Processing status');
var index = this.indexOfSubarray(data, [13, 10]);
var padding = 2;
if (index === -1) {
index = this.indexOfSubarray(data, [10]);
if (index === -1) {
this._errorRequest({
'message': 'Unknown server response.'
});
}
padding = 1;
}
var statusArray = data.subarray(0, index);
data = data.subarray(index + 2);
data = data.subarray(index + padding);
var statusLine = this.arrayBufferToString(statusArray);
statusLine = statusLine.replace(/HTTP\/\d(\.\d)?\s/, '');
var delimPos = statusLine.indexOf(' ');
Expand All @@ -1139,6 +1158,9 @@ class SocketFetch extends ArcEventSource {
if (status !== status) {
status = 0;
}
if (msg && msg.indexOf('\n') !== -1) {
msg = msg.split('\n')[0];
}
this._connection.status = status;
this._connection.statusMessage = msg;
this.log('Received status', this._connection.status, this._connection.statusMessage);
Expand All @@ -1153,10 +1175,17 @@ class SocketFetch extends ArcEventSource {
return;
}
this.log('Processing headers');
// if (!this._connection.headers) {
// this._connection.headers = '';
// }
// Looking for end of headers section
var index = this.indexOfSubarray(data, [13, 10, 13, 10]);
var padding = 4;
if (index === -1) {
// It can also be 2x ASCII 10
var _index = this.indexOfSubarray(data, [10, 10]);
if (_index !== -1) {
index = _index;
padding = 2;
}
}
// https://github.com/jarrodek/socket-fetch/issues/3
var enterIndex = this.indexOfSubarray(data, [13, 10]);
if (index === -1 && enterIndex !== 0) {
Expand Down Expand Up @@ -1189,7 +1218,7 @@ class SocketFetch extends ArcEventSource {
this._parseHeaders();
this.state = SocketFetch.BODY;
var start = index === -1 ? 0 : index;
var move = (enterIndex === 0) ? 2 : 4;
var move = (enterIndex === 0) ? 2 : padding;
data = data.subarray(start + move);

return this._postHeaders(data);
Expand Down Expand Up @@ -1497,7 +1526,8 @@ class SocketFetch extends ArcEventSource {
}
// Finishes the response with error message.
_errorRequest(opts) {
this._cleanUp();
this.aborted = true;
this.state = SocketFetch.DONE;
var message;
if (opts.code && !opts.message) {
message = this.getCodeMessage(opts.code);
Expand All @@ -1513,6 +1543,7 @@ class SocketFetch extends ArcEventSource {
error: error
});
this._cancelTimer();
this._cleanUp();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socket-fetch",
"version": "1.0.68",
"version": "1.0.69",
"license": "LICENSE.txt",
"description": "A HTTP transport based on chrome.socket.tcp API.",
"authors": [
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socket-fetch",
"version": "1.0.68",
"version": "1.0.69",
"license": "LICENSE",
"description": "A HTTP transport based on chrome.socket.tcp API.",
"repository": {
Expand Down

0 comments on commit 0209a61

Please sign in to comment.