better approach inspired by Apache HTTPRequest; usage example