When an option like --custom-header Authorization my-token is received this must be broken in to 3 strings to be given to subprocess.Popen
'custom-header'
'Authorization'
'my-token'
With the previous code where "Authorization my-token" was one string, Popen does not correctly pass both arguments with --custom-header. Consequently wkhtmltopdf ignores any --custom-header instruction sent to it from django-wkhtml. The problem can be seen by running these commands:
import subprocess
cmd = ['curl', '--dump-header output', 'https://api.github.com']
subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
(b'', b"curl: option --dump-header output: is unknown\ncurl: try 'curl --help' for more information\n")
When an option like --custom-header Authorization my-token is received this must be broken in to 3 strings to be given to subprocess.Popen
With the previous code where "Authorization my-token" was one string, Popen does not correctly pass both arguments with --custom-header. Consequently wkhtmltopdf ignores any --custom-header instruction sent to it from django-wkhtml. The problem can be seen by running these commands:
If you change the above command to be
cmd = ['curl', '--dump-header', 'output', 'https://api.github.com']
then the call works and makes a file called "output" containing header information.