clarkk
clarkk

Reputation: 1

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

Upvotes: 0

Views: 983

Answers (1)

NulledCoder
NulledCoder

Reputation: 265

You can check it with:

function isConnectionKeepAlive() {
    if(getallheaders()["Connection"] == "Keep-Alive") {
          return true;
    } else {
          return false;
    }
}

Upvotes: 1

Related Questions