refactor httpserver merge method