Extract codes from handle_request.c file