beast: Unable to accept request with specific filetypes in the body

So I had a bit of an issue and I’m already fairly sure that this is just something I don’t understand rather than a bug in the library.


For some reason, specific files aren't being accepted by the Boost::Beast server. I can add files in the body and with most files, it just keeps loading until I get a "Connection reset" error (using Postman). Sending images works, but any other filetype doesn't. For clarification:
  • Filesize isn’t the problem I have tested this with files of 10MB and files of 1 byte, both show the same results consistently
  • It’s not a problem of binary vs encoded (utf-8/ASCII/etc) files I have tested whether the same problem occurs on actual binary files (executables) and that didn’t change the results whatsoever either

The code:

I’m not using any insane functions or any 3rd-party libraries to help with this. I’m just using the native boost::beast::buffers_to_string(req.body().data()) function and outputting that back into the response body. With images this gives the expected output, it returns the raw data of the image, with any other filetypes (tested with txt files, zip files and executables) it doesn’t hive any response at all and Postman doesn’t recognize it accepting the request or giving a response.

libboost-dev-all version: focal 1.71.0.0ubuntu2 amd64

std::string req_body = boost::beast::buffers_to_string(req.body().data());
beast::ostream(res.body()) << req_body;

Thanks in advance for helping and taking the time to read this!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 28

Most upvoted comments

Wait… was this whole issue just because of Postman? If so, my sincere apologies for wasting your time

LOL! I never use these stupid GUI-based tools. They try to do clever stuff behind your back.

Great, I’ll take a look today