File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33namespace TraderInteractive \Util ;
44
55use Exception ;
6+ use InvalidArgumentException ;
67
78/**
89 * Static class with various HTTP related functions.
@@ -47,6 +48,10 @@ final class Http
4748 */
4849 public static function parseHeaders (string $ rawHeaders ) : array
4950 {
51+ if (empty ($ rawHeaders )) {
52+ throw new InvalidArgumentException ('$rawHeaders cannot be whitespace ' );
53+ }
54+
5055 $ headers = [];
5156 $ rawHeaders = preg_replace ("/ \r\n[ \t ]+/ " , ' ' , trim ($ rawHeaders ));
5257 $ fields = explode ("\r\n" , $ rawHeaders );
Original file line number Diff line number Diff line change @@ -97,6 +97,23 @@ public function parseHeadersMethodAndUrlSet()
9797 $ this ->assertSame ($ expected , $ result );
9898 }
9999
100+ /**
101+ * Verifies that the rawHeaders string cannot be whitespace.
102+ *
103+ * @test
104+ * @group unit
105+ * @covers ::parseHeaders
106+ *
107+ * @expectedException \InvalidArgumentException
108+ * @expectedExceptionMessage $rawHeaders cannot be whitespace
109+ *
110+ * @return void
111+ */
112+ public function parseHeadersWhitespace ()
113+ {
114+ Http::parseHeaders ('' );
115+ }
116+
100117 /**
101118 * @test
102119 * @covers ::buildQueryString
You can’t perform that action at this time.
0 commit comments