swifter icon indicating copy to clipboard operation
swifter copied to clipboard

Question:Why [UInt8] for request.body?

Open dengjing1994 opened this issue 6 years ago • 1 comments

I try to upload files by WLAN, but the speed is not as fast as expected. It looks like let rv = [UInt8](buffer[0..<bytesRead]) which located in Socket.swift cost much time. And the [UInt8] is for request.body.

I wonder why [Uint8] is used as the type of request.body? And will there be potential problem if I use another type(like Data) instead of [UInt8]?

I'm new for Swift and not good at English. Wish I have expressed my question properly.

dengjing1994 avatar Aug 07 '19 06:08 dengjing1994

`[UInt8] is just another way of representing a data blob. You can wrap it in a Data object and it will work fine, see this issue

TLDR: Data(request.body) will do what you want

chih98 avatar May 05 '23 17:05 chih98