Fixing bug that would cause the content-length header to be calculated wrongly.
Increasing indentation level.
Fixed a bug while with POST requests.
Removing comments regarding extra character sent with JSON request body, because I'm increasingly unsure about if it's correct.
Fixed potential buffer overflow bug, and added null termination of received  body (in case of overflow).
Improved Logging.