elnormous / HTTPRequest

Single-header C++ HTTP request class
The Unlicense
942 stars 213 forks source link

Json post bug #59

Open ce2020-ai opened 2 years ago

ce2020-ai commented 2 years ago

I built a request using nlohmann:: JSON and wrote the code according to the example, but I encountered the following bug:

terminate called after throwing an instance of 'std::length_error' what(): basic_string::_S_create Aborted

You should use a JSON library like https://github.com/nlohmann/json for JSON encoding. JSON is not a part of the HTTP standard (RFC 7231) so it is out of the scope of this library. I added an example on hot wo send a JSON POST in https://github.com/elnormous/HTTPRequest/commit/b6b87953e5a639ba6c88e574c6d972a728463da8.

Originally posted by @elnormous in https://github.com/elnormous/HTTPRequest/issues/38#issuecomment-882886699