24 $this->headerLines = [];
25 $this->headerLists = [];
26 $this->headerNames = [];
27 foreach ( $headers as $name => $value ) {
28 $this->headerNames[ strtolower( $name ) ] = $name;
30 $this->headerLines[$name] = $valueLine;
31 $this->headerLists[$name] = $valueParts;
58 if ( is_array( $value ) ) {
59 return [ array_values( $value ), implode(
', ', $value ) ];
61 return [ [ $value ], $value ];
73 $lowerName = strtolower( $name );
74 $origName = $this->headerNames[$lowerName] ??
null;
75 if ( $origName !==
null ) {
76 unset( $this->headerLines[$origName] );
77 unset( $this->headerLists[$origName] );
79 $this->headerNames[$lowerName] = $name;
80 $this->headerLines[$name] = $valueLine;
81 $this->headerLists[$name] = $valueParts;
92 $lowerName = strtolower( $name );
93 $origName = $this->headerNames[$lowerName] ??
null;
94 if ( $origName ===
null ) {
96 $this->headerNames[$lowerName] = $origName;
97 $this->headerLines[$origName] = $valueLine;
98 $this->headerLists[$origName] = $valueParts;
100 $this->headerLines[$origName] .=
', ' . $valueLine;
101 $this->headerLists[$origName] = array_merge( $this->headerLists[$origName],
112 $lowerName = strtolower( $name );
113 $origName = $this->headerNames[$lowerName] ??
null;
114 if ( $origName !==
null ) {
115 unset( $this->headerNames[$lowerName] );
116 unset( $this->headerLines[$origName] );
117 unset( $this->headerLists[$origName] );
138 $headerName = $this->headerNames[ strtolower( $name ) ] ??
null;
139 if ( $headerName ===
null ) {
142 return $this->headerLists[$headerName];
151 return isset( $this->headerNames[ strtolower( $name ) ] );
162 $headerName = $this->headerNames[ strtolower( $name ) ] ??
null;
163 if ( $headerName ===
null ) {
166 return $this->headerLines[$headerName];
187 foreach ( $this->headerNames as $lowerName => $name ) {
188 if ( $lowerName ===
'set-cookie' ) {
192 foreach ( $this->headerLists[$name] as $value ) {
193 $lines[] =
"$name: $value";
196 $lines[] =
"$name: " . $this->headerLines[$name];