@@ -54,26 +54,28 @@ export class FunctionsClient {
54
54
try {
55
55
let _headers : Record < string , string > = { }
56
56
let body : any
57
- if (
58
- ( typeof Blob !== 'undefined' && functionArgs instanceof Blob ) ||
59
- functionArgs instanceof ArrayBuffer
60
- ) {
61
- // will work for File as File inherits Blob
62
- // also works for ArrayBuffer as it is the same underlying structure as a Blob
63
- _headers [ 'Content-Type' ] = 'application/octet-stream'
64
- body = functionArgs
65
- } else if ( typeof functionArgs === 'string' ) {
66
- // plain string
67
- _headers [ 'Content-Type' ] = 'text/plain'
68
- body = functionArgs
69
- } else if ( typeof FormData !== 'undefined' && functionArgs instanceof FormData ) {
70
- // don't set content-type headers
71
- // Request will automatically add the right boundary value
72
- body = functionArgs
73
- } else {
74
- // default, assume this is JSON
75
- _headers [ 'Content-Type' ] = 'application/json'
76
- body = JSON . stringify ( functionArgs )
57
+ if ( functionArgs && ! Object . prototype . hasOwnProperty . call ( headers , 'Content-Type' ) ) {
58
+ if (
59
+ ( typeof Blob !== 'undefined' && functionArgs instanceof Blob ) ||
60
+ functionArgs instanceof ArrayBuffer
61
+ ) {
62
+ // will work for File as File inherits Blob
63
+ // also works for ArrayBuffer as it is the same underlying structure as a Blob
64
+ _headers [ 'Content-Type' ] = 'application/octet-stream'
65
+ body = functionArgs
66
+ } else if ( typeof functionArgs === 'string' ) {
67
+ // plain string
68
+ _headers [ 'Content-Type' ] = 'text/plain'
69
+ body = functionArgs
70
+ } else if ( typeof FormData !== 'undefined' && functionArgs instanceof FormData ) {
71
+ // don't set content-type headers
72
+ // Request will automatically add the right boundary value
73
+ body = functionArgs
74
+ } else {
75
+ // default, assume this is JSON
76
+ _headers [ 'Content-Type' ] = 'application/json'
77
+ body = JSON . stringify ( functionArgs )
78
+ }
77
79
}
78
80
79
81
const response = await this . fetch ( `${ this . url } /${ functionName } ` , {
0 commit comments