@@ -802,17 +802,17 @@ export class Upload extends Writable {
802802
803803 protected async createURIAsync ( ) : Promise < string > {
804804 const metadata = { ...this . metadata } ;
805- const headers = new Headers ( ) ;
805+ const headers : Record < string , string > = { } ;
806806
807807 // Delete content length and content type from metadata if they exist.
808808 // These are headers and should not be sent as part of the metadata.
809809 if ( metadata . contentLength ) {
810- headers . set ( 'X-Upload-Content-Length' , metadata . contentLength . toString ( ) ) ;
810+ headers [ 'X-Upload-Content-Length' ] = metadata . contentLength . toString ( ) ;
811811 delete metadata . contentLength ;
812812 }
813813
814814 if ( metadata . contentType ) {
815- headers . set ( 'X-Upload-Content-Type' , metadata . contentType ) ;
815+ headers [ 'X-Upload-Content-Type' ] = metadata . contentType ;
816816 delete metadata . contentType ;
817817 }
818818
@@ -828,7 +828,7 @@ export class Upload extends Writable {
828828 {
829829 idempotencyToken : this . currentInvocationId . uri ,
830830 gcclGcsCmd : this . #gcclGcsCmd,
831- }
831+ } ,
832832 ) ;
833833 this . currentInvocationId . uri = idempotencyToken ;
834834
@@ -869,18 +869,14 @@ export class Upload extends Writable {
869869 reqOpts . params . predefinedAcl = this . predefinedAcl ;
870870 }
871871
872- if ( this . origin ) {
873- const headers = new Headers ( reqOpts . headers ) ;
874- headers . set ( 'Origin' , this . origin ) ;
875- reqOpts . headers = headers ;
876- }
877872 const uri = await AsyncRetry (
878873 async ( bail : ( err : Error ) => void ) => {
879874 try {
880875 const res = await this . makeRequest ( reqOpts ) ;
881876 // We have successfully got a URI we can now create a new invocation id
882877 this . currentInvocationId . uri = crypto . randomUUID ( ) ;
883- return res . headers . get ( 'location' ) ;
878+ const respHeaders = new Headers ( res . headers ) ;
879+ return respHeaders . get ( 'location' ) ;
884880 } catch ( err ) {
885881 const e = err as GaxiosError ;
886882 if (
@@ -1007,7 +1003,7 @@ export class Upload extends Writable {
10071003 {
10081004 idempotencyToken : this . currentInvocationId . chunk ,
10091005 gcclGcsCmd : this . #gcclGcsCmd,
1010- }
1006+ } ,
10111007 ) ;
10121008 this . currentInvocationId . chunk = idempotencyToken ;
10131009
@@ -1219,7 +1215,7 @@ export class Upload extends Writable {
12191215 {
12201216 idempotencyToken : this . currentInvocationId . checkUploadStatus ,
12211217 gcclGcsCmd : this . #gcclGcsCmd,
1222- }
1218+ } ,
12231219 ) ;
12241220 this . currentInvocationId . checkUploadStatus = idempotencyToken ;
12251221
@@ -1320,7 +1316,7 @@ export class Upload extends Writable {
13201316 if ( combinedReqOpts . headers ) {
13211317 const headers = combinedReqOpts . headers as Record < string , unknown > ;
13221318 const userTokenKey = Object . keys ( headers ) . find (
1323- key => key . toLowerCase ( ) === 'x-goog-gcs-idempotency-token'
1319+ key => key . toLowerCase ( ) === 'x-goog-gcs-idempotency-token' ,
13241320 ) ;
13251321 const userTokenValue = userTokenKey ? headers [ userTokenKey ] : undefined ;
13261322 const hasValidUserToken =
@@ -1363,7 +1359,7 @@ export class Upload extends Writable {
13631359 if ( combinedReqOpts . headers ) {
13641360 const headers = combinedReqOpts . headers as Record < string , unknown > ;
13651361 const userTokenKey = Object . keys ( headers ) . find (
1366- key => key . toLowerCase ( ) === 'x-goog-gcs-idempotency-token'
1362+ key => key . toLowerCase ( ) === 'x-goog-gcs-idempotency-token' ,
13671363 ) ;
13681364 const userTokenValue = userTokenKey ? headers [ userTokenKey ] : undefined ;
13691365 const hasValidUserToken =
0 commit comments