clarkk clarkk - 1 year ago 85
PHP Question

Tell if HTTP request is Keep-Alive

How to tell if a HTTP request is a Keep-Alive connection?

Is it possible to detect via PHP if a HTTP request is Keep-Alive?

If a connection is not Keep-Alive I want to return an error as a part of the API protocol to reduce the use of resources at each SSL handshake and to speed up the communication between server and client

Answer Source

You can check it with:

function isConnectionKeepAlive() {
    if(getallheaders()["Connection"] == "Keep-Alive") {
          return true;
    } else {
          return false;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download