variable
variable

Reputation: 9664

Flask's request.data returns bytes data, however sometimes automatically decoded

I am using Postman to invoke a flask POST endpoint with an .xml file

For most of the .xml files the Flask's request.data returns bytes data (encoded). Example:

b'\xff\xfe\x001\x006........\r\x001\n\x00'

However, for couple of the files the value in the request.data is bytes but the contents looks to be automatically decoded. Example:

b'\xef\xbb\xbfsome human readable value here.....text\r\n'

What exactly is the cause of this behavior? I cannot see any striking difference between the xml files that give the above outputs.

Upvotes: 0

Views: 805

Answers (1)

Jürgen Gmach
Jürgen Gmach

Reputation: 6113

The second example is still byte code. It is not decoded, it just happens that certain byte values can be represented as ASCII chars.

So, nothing to worry.

Upvotes: 3

Related Questions