File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 44
55* [ #1271 ] ( https://github.com/mozilla/glean.js/pull/1271 ) : BUGFIX: Fix pings validation function when scanning pings database on initialize.
66 * This bug was preventing pings that contained custom headers from being successfully validated and enqueued on initialize.
7+ * [ #] ( ) : BUGFIX: Fix uploading gzip-compressed pings in Node.
78
89# v1.0.0 (2022-03-17)
910
Original file line number Diff line number Diff line change 55import https from "https" ;
66import http from "http" ;
77
8+ import { isString } from "../../core/utils.js" ;
89import log , { LoggingLevel } from "../../core/log.js" ;
910import Uploader , {
1011 UploadResult ,
@@ -55,7 +56,7 @@ class NodeUploader extends Uploader {
5556 } ) ;
5657
5758 // Finish sending the request.
58- request . end ( body ) ;
59+ request . end ( isString ( body ) ? body : Buffer . from ( body . buffer ) ) ;
5960 } ) ;
6061 }
6162}
Original file line number Diff line number Diff line change @@ -17,14 +17,18 @@ describe("Uploader/Node", function () {
1717
1818 it ( "returns the correct status for successful requests" , async function ( ) {
1919 for ( const status of [ 200 , 400 , 500 ] ) {
20- nock ( MOCK_ENDPOINT ) . post ( / ./ i) . reply ( status ) ;
21-
22- const response = NodeUploader . post ( MOCK_ENDPOINT , "" ) ;
23- const expectedResponse = new UploadResult ( UploadResultStatus . Success , status ) ;
24- assert . deepStrictEqual (
25- await response ,
26- expectedResponse
27- ) ;
20+ // We support both plain text and binary payloads (for gzipped content)
21+ // so test them both.
22+ for ( const body of [ "" , new Uint8Array ( ) ] ) {
23+ nock ( MOCK_ENDPOINT ) . post ( / ./ i) . reply ( status ) ;
24+
25+ const response = NodeUploader . post ( MOCK_ENDPOINT , body ) ;
26+ const expectedResponse = new UploadResult ( UploadResultStatus . Success , status ) ;
27+ assert . deepStrictEqual (
28+ await response ,
29+ expectedResponse
30+ ) ;
31+ }
2832 }
2933 } ) ;
3034
You can’t perform that action at this time.
0 commit comments