}
} else {
- len = sprintf(buf, "Status: %d\r\n", SG(sapi_headers).http_response_code);
+ char *s;
+
+ if (SG(sapi_headers).http_status_line &&
+ (s = strchr(SG(sapi_headers).http_status_line, ' ')) != 0 &&
+ (s - SG(sapi_headers).http_status_line) >= 5 &&
+ strncasecmp(SG(sapi_headers).http_status_line, "HTTP/", 5) == 0) {
+ len = sprintf(buf, "Status:%s\r\n", s);
+ } else {
+ len = sprintf(buf, "Status: %d\r\n", SG(sapi_headers).http_response_code);
+ }
}
PHPWRITE_H(buf, len);