Improved cgi-script handling

(1) Fixed PATH_INFO calculation.
(2) Handles redirection response.