supabase-community/functions-swift

Content-Type header should not be overridden

iamjamesim opened this issue · 4 comments

Bug report

Describe the bug

FunctionInvokeOptions overrides the specified Content-Type header value to application/octet-stream when body is of type Data.

To Reproduce

let boundary = "Boundary-\(UUID().uuidString)"
let contentType = "multipart/form-data; boundary=\(boundary)"
let options = FunctionInvokeOptions(
  headers: ["Content-Type": contentType],
  body: "binary value".data(using: .utf8)!
)
print(options.headers)

Output

["Content-Type": "application/octet-stream"]

Expected behavior

Functions are invoked with the specified Content-Type header value.

System Information

  • functions-swift: 1.0.0

Additional context

I'm trying to invoke a function that handles multipart/form-data requests (based on this example function).

I have a potential fix here. Happy to open a PR if it makes sense.

Hi @iamjamesim sorry for the late response.

Feel free to PR your fix, it would be of great help.

@grdsdev please take a look at the open PR when you get a chance. Just hoping to point my projects back to this repo instead of my fork. Thanks!