How to set custom-header connection to upgrade
RossAWaddell opened this issue · comments
I can't figure out how to set the Connection property for the request header. It looks like it could be a name/value pair in an array, but nothing seems to work. I need to send 'keep-alive,upgrade' to avoid a memory issue with wkhtmltopdf on some production environments as outlined here.
I've tried this:
$snappy->setOption('custom-header', array('Connection' => 'Keep-Alive', 'Connection' => 'Upgrade')); $snappy->setOption('custom-header-propagation', true);
and this:
$snappy->setOption('custom-header', array('Connection' => 'Keep-Alive, Upgrade')); $snappy->setOption('custom-header-propagation', true);
But to no avail. When I look in FF developer tools (network) I always see this in the request header:
Host: localhost User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:63.0) Gecko/20100101 Firefox/63.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive Upgrade-Insecure-Requests: 1 Cache-Control: max-age=0
I'm using wkhtmltopdf 0.12.5 and Snappy 1.0.4
Hello,
The correct way to define custom headers is the following:
$snappy->setOption(
'custom-header',
array(
'X-Custom-Header-1' => 'value1',
'X-Custom-Header-2' => 'value2',
)
);
If you specify the same header multiple times only the last one will be used.
I don't understand why do you expect to see your custom headers from FF developer tools as, those headers, are used in the request made by wkhtmltopdf
server side.