Streamhandling in NetJavaImpl plus tests for POST

This fixes some possibly unclosed streams (especially if an  error is returned in the http response) and adds tests for the error case and a POST request in NetAPITest.