Skip to content
Advertisement

Python call to PHP – malformed header from script Bad header: Array

Very strange – I’ve been using a python script that scrapes data and then passes it to a php-script – Worked like charm for weeks, until today something happened.

I got the following message from apache2 errorlog:

JavaScript

So it seems to be derived from this python script, the php-script is called but there is a server 500 error and the error log tells about a malformed header from python

python script

JavaScript

the php script (snippet)

JavaScript

Any Idea whats wrong, why this suddenly happened? Could a packetsniffer be in place to see whats going on?

Advertisement

Answer

I solved the problem by flushing the outputstream buffer

More precisely I changed the printfunction from:

print (“Content-type: text/htmlrnrn”)

to:

print (“Content-type: text/html”, end=”rnrn”, flush=True)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement