apollo-link-http
Advanced tools
Comparing version 1.6.0-alpha.0 to 1.6.0-alpha.1
@@ -108,8 +108,23 @@ (function (global, factory) { | ||
// See: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html | ||
var payloads = plaintext.split('\r\n---\r\n'); | ||
for (var _i = 0, payloads_1 = payloads; _i < payloads_1.length; _i++) { | ||
var payload = payloads_1[_i]; | ||
if (payload.length && payload !== '\r\n---') { | ||
// Terminator | ||
observer.next(JSON.parse(payload)); | ||
var boundary = '\r\n---\r\n'; | ||
var terminatingBoundary = '\r\n-----\r\n'; | ||
var parts = plaintext.split(boundary); | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
// Get the body of the part, we don't need the headers for | ||
// each part, but it is sent anyway as per the spec. | ||
if (part.length) { | ||
var partArr = part.split('\r\n\r\n'); | ||
if (!partArr || partArr.length !== 2) { | ||
throw new Error('Invalid multipart response from GraphQL server'); | ||
} | ||
var body_1 = partArr[1]; | ||
if (body_1 && body_1.length) { | ||
// Strip out the terminating boundary | ||
body_1 = body_1.replace(terminatingBoundary, ''); | ||
observer.next(JSON.parse(body_1)); | ||
} | ||
else { | ||
throw new Error('Invalid multipart response from GraphQL server'); | ||
} | ||
} | ||
@@ -128,2 +143,3 @@ } | ||
else { | ||
reader_1.releaseLock(); | ||
observer.complete(); | ||
@@ -130,0 +146,0 @@ } |
@@ -105,8 +105,23 @@ var __extends = (this && this.__extends) || (function () { | ||
// See: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html | ||
var payloads = plaintext.split('\r\n---\r\n'); | ||
for (var _i = 0, payloads_1 = payloads; _i < payloads_1.length; _i++) { | ||
var payload = payloads_1[_i]; | ||
if (payload.length && payload !== '\r\n---') { | ||
// Terminator | ||
observer.next(JSON.parse(payload)); | ||
var boundary = '\r\n---\r\n'; | ||
var terminatingBoundary = '\r\n-----\r\n'; | ||
var parts = plaintext.split(boundary); | ||
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { | ||
var part = parts_1[_i]; | ||
// Get the body of the part, we don't need the headers for | ||
// each part, but it is sent anyway as per the spec. | ||
if (part.length) { | ||
var partArr = part.split('\r\n\r\n'); | ||
if (!partArr || partArr.length !== 2) { | ||
throw new Error('Invalid multipart response from GraphQL server'); | ||
} | ||
var body_1 = partArr[1]; | ||
if (body_1 && body_1.length) { | ||
// Strip out the terminating boundary | ||
body_1 = body_1.replace(terminatingBoundary, ''); | ||
observer.next(JSON.parse(body_1)); | ||
} | ||
else { | ||
throw new Error('Invalid multipart response from GraphQL server'); | ||
} | ||
} | ||
@@ -125,2 +140,3 @@ } | ||
else { | ||
reader_1.releaseLock(); | ||
observer.complete(); | ||
@@ -127,0 +143,0 @@ } |
{ | ||
"name": "apollo-link-http", | ||
"version": "1.6.0-alpha.0", | ||
"version": "1.6.0-alpha.1", | ||
"description": "HTTP transport layer for GraphQL", | ||
@@ -5,0 +5,0 @@ "author": "Evans Hauser <evanshauser@gmail.com>", |
@@ -143,7 +143,26 @@ import { | ||
// See: https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html | ||
const payloads = plaintext.split('\r\n---\r\n'); | ||
for (const payload of payloads) { | ||
if (payload.length && payload !== '\r\n---') { | ||
// Terminator | ||
observer.next(JSON.parse(payload) as FetchResult); | ||
const boundary = '\r\n---\r\n'; | ||
const terminatingBoundary = '\r\n-----\r\n'; | ||
const parts = plaintext.split(boundary); | ||
for (const part of parts) { | ||
// Get the body of the part, we don't need the headers for | ||
// each part, but it is sent anyway as per the spec. | ||
if (part.length) { | ||
let partArr = part.split('\r\n\r\n'); | ||
if (!partArr || partArr.length !== 2) { | ||
throw new Error( | ||
'Invalid multipart response from GraphQL server', | ||
); | ||
} | ||
let body = partArr[1]; | ||
if (body && body.length) { | ||
// Strip out the terminating boundary | ||
body = body.replace(terminatingBoundary, ''); | ||
observer.next(JSON.parse(body) as FetchResult); | ||
} else { | ||
throw new Error( | ||
'Invalid multipart response from GraphQL server', | ||
); | ||
} | ||
} | ||
@@ -160,2 +179,3 @@ } | ||
} else { | ||
reader.releaseLock(); | ||
observer.complete(); | ||
@@ -162,0 +182,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110687
1808