@@ -91,14 +91,14 @@ public static function parseRawHeader($rawHeader)
9191 * Returns a list of headers from a key/value paired array.
9292 *
9393 * @param array $headers Headers as key/value pairs.
94- * @return array List of headers [' Content-Type: text/html' , '...'].
94+ * @return array List of headers [" Content-Type: text/html\r\n" , '...'].
9595 */
9696 public static function formatHeadersForCurl (array $ headers )
9797 {
9898 $ curlHeaders = array ();
9999
100100 foreach ($ headers as $ key => $ value ) {
101- $ curlHeaders [] = $ key . ': ' . $ value ;
101+ $ curlHeaders [] = $ key . ': ' . $ value . "\r\n" ;
102102 }
103103
104104 return $ curlHeaders ;
@@ -108,25 +108,30 @@ public static function formatHeadersForCurl(array $headers)
108108 * Returns a HTTP status line from specified response.
109109 *
110110 * @param Response $response
111+ *
111112 * @return string HTTP status line.
112113 */
113114 public static function formatAsStatusString (Response $ response )
114115 {
115116 return 'HTTP/ ' . $ response ->getHttpVersion ()
116- . ' ' . $ response ->getStatusCode ()
117- . ' ' . $ response ->getStatusMessage ();
117+ . ' ' . $ response ->getStatusCode ()
118+ . ' ' . $ response ->getStatusMessage ()
119+ . "\r\n" ;
118120 }
119121
120122 /**
121123 * Returns a HTTP status line with headers from specified response.
122124 *
123125 * @param Response $response
126+ *
124127 * @return string HTTP status line.
125128 */
126129 public static function formatAsStatusWithHeadersString (Response $ response )
127130 {
128131 $ headers = self ::formatHeadersForCurl ($ response ->getHeaders ());
129132 array_unshift ($ headers , self ::formatAsStatusString ($ response ));
130- return join ("\r\n" , $ headers ) . "\r\n\r\n" ;
133+
134+ // Only one \r\n, as self::formatHeadersForCurl() returns an empty line as the last header already;
135+ return join ('' , $ headers ) . "\r\n" ;
131136 }
132137}
0 commit comments