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

Commit 3452e44

Browse files
committed
1 parent f53dcff commit 3452e44

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

app.fetch.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,12 @@ class SocketFetch extends ArcEventSource {
10891089
if (!this._connection.chunkSize) {
10901090
data = this.readChunkSize(data);
10911091
this.log('Chunk size: ', this._connection.chunkSize);
1092+
if (this._connection.chunkSize === null) {
1093+
// It may happen that chrome's buffer cuts the data
1094+
// just before the chunk size.
1095+
// It should proceed it in next portion of the data.
1096+
return;
1097+
}
10921098
if (!this._connection.chunkSize) {
10931099
this.onResponseReady();
10941100
return;
@@ -1290,6 +1296,10 @@ class SocketFetch extends ArcEventSource {
12901296
}
12911297
var sizeArray = array.subarray(0, index);
12921298
var sizeHex = this.arrayBufferToString(sizeArray);
1299+
if (!sizeHex || sizeHex === '') {
1300+
this._connection.chunkSize = null;
1301+
return array.subarray(index + 2);
1302+
}
12931303
this._connection.chunkSize = parseInt(sizeHex, 16);
12941304
return array.subarray(index + 2);
12951305
}

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket-fetch",
3-
"version": "1.0.41",
3+
"version": "1.0.42",
44
"license": "LICENSE.txt",
55
"description": "A HTTP transport based on chrome.socket.tcp API.",
66
"authors": [

demo/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ <h2>Log</h2>
133133

134134
demo.addEventListener('dom-change', function() {
135135
// demo.set('url', 'https://chromerestclient.appspot.com/test?p=json');
136-
demo.set('url', 'http://localhost:8081/redirect');
136+
// demo.set('url', 'http://localhost:8081/redirect');
137+
demo.url = 'https://httpbin.org/range/75776?chunk_size=150';
137138
demo.set('payload', '{"test":"request"}');
138-
demo.set('method', 'POST');
139+
demo.set('method', 'GET');
139140
demo.set('headers',
140141
`Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
141142
Accept-Encoding: gzip, deflate
@@ -165,7 +166,7 @@ <h2>Log</h2>
165166
demo.push('logs', {
166167
log: 'Received response.'
167168
});
168-
console.log('Fetch result', result);
169+
// console.log('Fetch result', result);
169170
})
170171
.catch((cause) => {
171172
demo.push('logs', {
@@ -179,7 +180,7 @@ <h2>Log</h2>
179180
demo.push('logs', {
180181
log: log
181182
});
182-
console.log('Fetch result', response);
183+
// console.log('Fetch result', response);
183184
}
184185
})
185186
.catch((cause) => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "socket-fetch",
3-
"version": "1.0.41",
3+
"version": "1.0.42",
44
"license": "LICENSE",
55
"description": "A HTTP transport based on chrome.socket.tcp API.",
66
"scripts": {

0 commit comments

Comments
 (0)