+ } else if (msg->type == PHP_HTTP_REQUEST) {
+ if ((h = php_http_message_header(msg, ZEND_STRL("Transfer-Encoding"), 0))) {
+ zval_ptr_dtor(&h);
+ } else {
+ /* no filter, no CR, no size, no TE, no CL */
+ if (0 <= php_http_select_str(msg->http.info.request.method, 3, "POST", "PUT", "PATCH")) {
+ /* quoting RFC7230#section-3.3.2
+ A user agent SHOULD send a Content-Length in a request message when
+ no Transfer-Encoding is sent and the request method defines a meaning
+ for an enclosed payload body. For example, a Content-Length header
+ field is normally sent in a POST request even when the value is 0
+ (indicating an empty payload body). A user agent SHOULD NOT send a
+ Content-Length header field when the request message does not contain
+ a payload body and the method semantics do not anticipate such a
+ body.
+ */
+ MAKE_STD_ZVAL(h);
+ ZVAL_LONG(h, 0);
+ zend_hash_update(&msg->hdrs, "Content-Length", sizeof("Content-Length"), &h, sizeof(zval *), NULL);
+ }
+ }