Score:0

can http clients configure if they want persistent or non-persistent connections with the http server?

ua flag

I want to understand, if depending on how client configures the http connection, the server can behave in non-persistent manner or persistent manner, so in effect some clients can connect in persistent mode and some clients can connect in non-persistent mode.

Any sample code esp in java would be helpful.

Score:0
cn flag

This depends on the protocol version:

HTTP/1.0

(For the elder among us). Connections are immediately closed unless specified otherwise. To keep a connection alive, the client can add a Connection: keep-alive header to the request. If the server supports this and agrees, the connection is kept alive. If either party no longer wants to keep the connection (e.g., the client no longer adds said header, or adds Connection: close), the connection is closed after the request completes.

HTTP/1.1

Here the default is to keep the connection open, unless specifically declared otherwise (Connection: close). However, the server may decide to close the connection after some inactivity timeout (e.g., 5 seconds). Then again, you can never force a server to keep the connection up, but making a dummy request every 4 seconds might work - but this should really be a request that causes almost no load at all to the server, and as a server admin, I'd even be annoyed by lots of pesky lines in the log file.

I won't go deeper into HTTP/2 because the multiplexing and serv push options make the situation a bit complex.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.