Fixed CID-13261 broken memcpy()

We actually intentionally leak the stream resources so we don't actually
need to copy the content of the context, only the pointer
CID 20060: Resource leak (RESOURCE_LEAK)
CID 19803 / 19802 / 19737 free error_message on failure
CID 19738 (and probably others) freeing error_message on failure

...Also, actually fail when we can't read all the data we were supposed to be able to
(eg. the network cable is ripped out after we get the header!)
Fix error codes