[enh] Set proper HTTP status code depending on the request result