"uri" should not be altered (since the variable is laterwards used for logging)
always use finish() to send the output / log the request
simplify the path parsing
remove unnecessary check; pathname always start from "/" (or should we assert instead?)