Epiphany doesn't show PDF as response to a POST
Hello!
I'm not experienced with PHP. I've created a HTML form which uses a HTTP POST to a PHP Script and returns a PDF. This works fine with Firefox, Chrome, cURL and Midori (WebKit2). It also works fine, when I copy the cURL command from the Web Inspector and execute it manually with --output some.pdf
. But Epiphany waits forever when I fill the first name and press the button labeled "PDF".
This is the PHP, using TCPPDF:
<?php
if (isset($_POST['pdf_button'])) {
header('Content-Type: application/pdf');
require_once('tcpdf/tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Foo Bar');
$pdf->SetTitle('Check');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('tcpdf, oepnv');
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('dejavusans', '', 14, '', true);
// add a page
$pdf->AddPage();
$pdf->Text(20, 20, 'TEST');
// set style for barcode
$style = array(
'border' => 2,
'vpadding' => 'auto',
'hpadding' => 'auto',
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255)
'module_width' => 1, // width of a single module in points
'module_height' => 1 // height of a single module in points
);
// QRCODE,Q : QR-CODE Better error correction
$pdf->write2DBarcode('Hello WebKit', 'QRCODE,Q', 20, 50, 50, 50, $style, 'N');
// $pdf->write2DBarcode($first_name, 'QRCODE,Q', 20, 50, 50, 50, $style, 'N');
$pdf->Text(20, 40, 'ÖPNV Ticket');
//Close and output PDF document
$pdf->Output('pdf_ticket.pdf', 'D'); // I for inline
} else {
echo 'Hello ' . htmlspecialchars($_POST["first_name"]) . ' ' . htmlspecialchars($_POST["last_name"]) . '!'; // dot is concatenation operator
}
?>
The supposed "cURL" Epiphany seems to use:
curl 'https://flapflap.eu/work.php' \
-X 'POST' \
-H 'Referer: https://flapflap.eu/form.html' \
-H 'Origin: https://flapflap.eu' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15' \
--data 'first_name=Foo&last_name=&pdf_button=PDF' --output test.pdf
Now to the interesting part. Epiphany somewhat struggles with the MIME-TYPE, it only shows this in the terminal output:
(epiphany:9465): epiphany-WARNING **: 16:54:21.259: PDF file:///tmp/work.php has invalid MIME type: text/html
$ cat /tmp/work.php
reveals:
Hello !
This looks like the result of the else branch. I should mention, that Nautilus is holding a FTP connection to my website, but I cannot imagine a connection between the FTP and the issue. Requesting a PDF with a plain HTTP GET works fine.
Thank you