Network Failure while download Using PHP Script - php

I am getting network failure message in chrome but working on other browser using php download script.
I have below headers set to download.
cache-control: must-revalidate, post-check=0, pre-check=0
content-disposition: attachment; filename="export.csv"
content-length: 388436
content-type: application/octet-stream
date: Thu, 19 Jul 2018 13:41:02 GMT
expires: Wed, 19 Jul 2017 13:40:59 GMT
last-modified: Thu, 19 Jul 2018 13:41:02 GMT
pragma: public
server: nginx
set-cookie: admin=p5t1vd4e4u3j9g6gto5h046ki0; path=/admin; domain=xyz.com; secure; HttpOnly
status: 200
x-powered-by: PHP/7.0.29
I am getting error in chrome version 67.3396.99

Related

Wordpress Site not Connecting thru online Cron Job Service

I am running a wordpress site and using an online cron job service to connect.
When i connect thru the service im getting "HTTP/1.1 404 Not Found" error.
This is the cron job link im using:
http://www.moongot.com/wp-content/plugins/WPFanMachineBasic/auto.php
This is the output:
X-Powered-By: PHP/5.5.22 Pragma: no-cache Date: Sat, 14 Apr 2018
22:00:59 GMT Content-Length: 4 Server: Apache/2 Set-Cookie:
PHPSESSID=3ef1b912c68e0502d03caccb87e0858b; path=/ Expires: Wed, 11
Jan 1984 05:00:00 GMT Cache-Control: no-cache, must-revalidate,
max-age=0 X-Endurance-Cache-Level: 2 Content-Type: text/html;
charset=UTF-8
DONE
I get the same via cURL:
curl -I http://www.moongot.com/wp-content/plugins/WPFanMachineBasic/auto.php
HTTP/1.1 404 Not Found
Date: Sat, 14 Apr 2018 22:29:13 GMT
Content-Type: text/html
Content-Length: 863
Connection: keep-alive
Keep-Alive: timeout=30
Server: Apache/2
X-Powered-By: PHP/5.5.22
Set-Cookie: PHPSESSID=2df00eb1132bf607a708d00aee845f8a; path=/
Pragma: no-cache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Last-Modified: Wed, 02 Aug 2017 19:17:35 GMT
Accept-Ranges: bytes
and in Chrome:
So you'll want to figure out why your auto.php file is spitting out a 404 header.

Magento does not set cookie on product/category page

So here is the issue, Magento doesn't seem to set-cookie on product/category page.
It doesn't show any cart items or customer login information on product page, however all the items appear fine on home page and rest of the pages on site.
I checked headers for two of the pages.
Here is the product page:
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Tue, 15 Mar 2016 05:01:57 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Vary: Accept-Encoding
X-Cacheable: NO:Cache-Control=no-cache
Accept-Ranges: bytes
X-Served-From-Cache: Yes
Here is the home page headers (which is working fine)
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Tue, 15 Mar 2016 05:02:12 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Set-Cookie: frontend=n7m2mbnoo861h84r9ma40of221; expires=Wed, 16-Mar-2016 05:02:12 GMT; path=/store/; domain=-----; HttpOnly
Vary: Accept-Encoding
X-Cacheable: NO:Cache-Control=no-cache
Accept-Ranges: bytes
X-Served-From-Cache: Yes
Any idea what's happening?
I have tried increasing cookie lifetime to 86400
and cookie path to /store/ and cookie domain to (www.mydomain.com)
It turns out issue was misconfiguration of varnish on server. It was serving cached pages. Solution: Restarted varnish.

Readfile image not working on PHP

I have the below PHP code to load image
header('Content-Type: image/'.$contentFormat);
header('Content-Length: '. filesize($image));
readfile($image);
When I request the url in console I get the bellow header response
HTTP/1.1 200 OK
Date: Fri, 28 Nov 2014 13:13:59 GMT
Content-Type: image/jpeg
Content-Length: 107885
Connection: keep-alive
Keep-Alive: timeout=30
Server: Apache/2
X-Powered-By: PHP/5.3.13
Set-Cookie: PHPSESSID=617a3a6eba912178f810f10cc5d171f3; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Accept-Ranges: bytes
Age: 0
ÿØÿà
including ÿØÿà,
What could be the problem? I searched all my php files for whitespace. Any guess or suggestions where I can search for the whitespace

Setting content-type using nginx and PHPExcel

I'm developing a site using Zend Framework 2 where the client wanted to be able to export some data to an Excel file. For this I went with PHPExcel, and I got it working on my local computer, where I run Apache2.
<?php
//Create a writer for Excel
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
// Get the data from php://output
// https://stackoverflow.com/questions/16551375/phpexcel-in-zend2-controller
ob_flush();
ob_start();
$objWriter->save('php://output');
$excelOutput = ob_get_clean();
//Get a new response object
$response = new \Zend\Http\Response();
//Set headers for the response object
$response->getHeaders()
->addHeaderLine('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT')
->addHeaderLine('Cache-Control: no-store, no-cache, must-revalidate')
->addHeaderLine('Cache-Control: post-check=0, pre-check=0')
->addHeaderLine('Pragma: no-cache')
->addHeaderLine('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
->addHeaderLine('Content-Disposition: attachment;filename="report.xlsx"');
//Set the content for the response object
$response->setContent($excelOutput);
return $response;
?>
The problem is that when I uploaded the project to my production server, running Nginx with a pretty standard setup using PHP-FPM, the Excel file isn't sent using the correct headers. It seems like they are overwritten with "text/html" which makes the browser show some garbled characters instead of making the file available for download.
I followed this (PHPExcel in Zend2 Controller) question for getting the content into a variable.
I can't figure out why this is happening, are the headers set differently using PHP on Apache2 than running Nginx with PHP-FPM?
Update: Returned headers
Apache on local computer:
HTTP/1.1 200 OK
Date: Sun, 11 May 2014 11:24:09 GMT
Server: Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.19
X-Powered-By: PHP/5.4.19
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
Last-Modified: Sun, 11 May 2014 11:24:09 GMT
Content-Disposition: attachment;filename="report.xlsx"
Content-Length: 6551
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Nginx headers:
HTTP/1.1 200 OK
Server: nginx/1.1.19
Date: Sun, 11 May 2014 11:14:18 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.10-1ubuntu3.11
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Encoding: gzip

multiple PHPSESSID cookies and browser doesn't keep any

I'm getting 2 PHPSESSID set cookies headers from a login request from my yii application.
Date: Thu, 05 Dec 2013 02:19:44 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3
Set-Cookie: PHPSESSID=3lkhjlsv967n56horpcl3n7gl5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=sctb6cd1snbd5g2esv1mn2lug7; path=/
Content-Length: 3
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
And browser doesn't keep any and doesn't send back them for future requests. Any idea how this is happening?

Categories