refactor connection handler to http resource. Rewrite the test and http resource