2021-11-09 711次浏览

Version 1.2.0 of yiisoft/http package was released.

HeaderValueHelper was added. It allows parsing various string header values into more convenient data structures.

use Yiisoft\Http\HeaderValueHelper;

// Result: ['a' => '1', 'b' => '2']
HeaderValueHelper::getParameters('a=1;b=2');

// Result: ['value', 'a' => '1', 'b' => '2']
HeaderValueHelper::getValueAndParameters('value;a=1;b=2'));

// Result: [['value2', 'q' => 1.0], ['value1', 'q' => 0.2]]
HeaderValueHelper::getSortedValueAndParameters('value1;q=0.2,value2'));

// Result: ['text/xml', 'text/html']
HeaderValueHelper::getSortedAcceptTypes('text/html;q=0.2,text/xml;q=0.4'));