WeTransfer / Mocker

Mock Alamofire and URLSession requests without touching your code implementation
MIT License
1.1k stars 96 forks source link

Optional dataType for empty body #134

Closed chkpnt closed 1 year ago

chkpnt commented 1 year ago

In my opinion, dataType should be optional in order to allow a response without a Content-Type for an empty body. This would also allow us to use Content-Type in additionalHeaders, as Content-Type is currently always overwritten by dataType.headerValue, which might be useful if you do not to spread your headers over two parameters.

An alternative would be to provide a DataType

    public static let none = Mock.DataType(name: "none", headerValue: "")

and to ensure, that Content-Type is written to header only if dataType.headerValue is not empty.

Which approach do you prefer? I'm open to file a PR if you wish me to do so.

AvdLee commented 1 year ago

@chkpnt this makes total sense to me (e.g. 202 responses). Making DataType optional makes most sense to me, since none is not a data type strictly said.

We would be happy to receive a contribution! 🙏