user1611817
user1611817

Reputation: 41

PHP Close Header

I have an app which connects to my web server and transfers data via XML. The headers I connect with are:

POST /app/API/Data/Receiver.php HTTP/1.1
User-Agent: Custom User Agent 1.0.0
Accept: text/xml
Content-Type: text/xml
Content-Length: 1580
Host: servername.com

The app then handles the data and returns its own XML formatted reply. One of the header's I'm setting in the response is:

header("Connection: close");

When I send connect and send my data from a simple app on my PC (C++) it works fine, I get the close header correctly and the connection is closed as soon as the data is available. When I send the exact same data using a GSM modem and and embedded app, the connection header comes back as:

header("Connection: keep-alive");

The GSM modem also sits and waits until the connection is closed before moving on and often just times out.

Is there someway to close the connection on the server so that the GSM side does not time out?

Upvotes: 4

Views: 2511

Answers (2)

sumnulu
sumnulu

Reputation: 3512

It is possible that your GSM service provider transparently proxing connections. Try to send data on non-standard port (i.e not 80, 8080, 443)

Also setting cache control header private might work.

Cache-Control: PRIVATE

Upvotes: 2

Cole Tobin
Cole Tobin

Reputation: 9429

Headers are just plain text but cannot be sent once data has been sent in PHP. Try this:

echo "\r\n\r\nConnection: close";
die();

and adjust to your needs

Upvotes: 0

Related Questions