Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-07

THTTPApplication does not close the TCP Connection

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jansen, Dirk

Hello,

I tested a simple http application and found that the THTTPApplication does not close the connection.

A normal web server always close the connection after sending the HTML page but this webserver does not close the connection. As a result of this every second request from a web browser (Firefox, IE) does not work. The browser starts the request than it waits for a very long time. If you interrupt the browser and start a new request you get an answer.

Does somebody know something about this.

Dirk

Reply by email

Michael Van Canneyt
to Jansen, Dirk
Dirk wrote 10 lines
Hello, I tested a simple http application and found that the THTTPApplication does not close the connection. A normal web server always close the connection after sending the HTML page but this webserver does not close the connection. As a result of this every second request from a web browser (Firefox, IE) does not work. The browser starts the request than it waits for a very long time. If you interrupt the browser and start a new request you get an answer.

That is not correct.

In HTTP 1.1 The browser sends a HTTP header which determines if the connection should be closed or not.

Secondly, THTTPApplication is an apache module. There it is apache which determines what happens to the connection, not the FPC code.

Michael.

Reply by email

Jansen, Dirk
to Michael Van Canneyt
> I tested a simple http application and found that the

THTTPApplication

> does not close the connection. > > A normal web server always close the connection after sending the

HTML

page but this webserver does not close the connection. As a result of this every second request from a web browser (Firefox, IE) does not work. The browser starts the request than it waits for a very long

time.

If you interrupt the browser and start a new request you get an

answer.

That is not correct. In HTTP 1.1 The browser sends a HTTP header which determines if the

connection should be closed or not.

Secondly, THTTPApplication is an apache module. There it is apache

which determines what happens to the

connection, not the FPC code.

The THTTPApplication is part of the standalone "HTTP server Application" (default project) of the weblazextra package. There is no apache server involved.

There is no difference if I user http 1.0, http 1.1 or if I set "Connection: close".

It is also impossible to send a second request over the open connection.

I just created an empty HTTP server Application project, defined an default action and tested this with
telnet localhost 8080
GET / HTTP/1.0

Dirk

Reply by email

Michael Van Canneyt
to Jansen, Dirk
Dirk wrote 30 lines
>> I tested a simple http application and found that the THTTPApplication >> does not close the connection. >> >> A normal web server always close the connection after sending the HTML > page but this webserver does not close the connection. As a result of > this every second request from a web browser (Firefox, IE) does not > work. The browser starts the request than it waits for a very long time. > If you interrupt the browser and start a new request you get an answer. > That is not correct. > In HTTP 1.1 The browser sends a HTTP header which determines if the connection should be closed or not. > Secondly, THTTPApplication is an apache module. There it is apache which determines what happens to the > connection, not the FPC code. The THTTPApplication is part of the standalone "HTTP server Application" (default project) of the weblazextra package. There is no apache server involved. There is no difference if I user http 1.0, http 1.1 or if I set "Connection: close". It is also impossible to send a second request over the open connection.

I have tested, and a strace shows that the connection is always closed:

accept(3, {sa_family=AF_INET, sin_port=htons(59845), sin_addr=inet_addr("127.0.0.1")}, [16]) = 4 mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc61cecb000 recvfrom(4, "GET /me.html HTTP/1.1\r\nHost: loc"..., 4096, 0, NULL, NULL) = 1801 mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc61cec3000 write(1, "Treating URI : /me.html\n", 24Treating URI : /me.html ) = 24
mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc61cebb000 access("/home/michael/FPC/trunk/packages/fcl-web/examples/httpserver/me.html", F_OK) = -1 ENOENT (No such file or directory) sendto(4, "HTTP/1.1 404 Not Found\r\nStatus: "..., 67, 0, NULL, 0) = 67 munmap(0x7fc61cecb000, 32768) = 0
close(4) = 0
accept(3, {sa_family=AF_INET, sin_port=htons(59846), sin_addr=inet_addr("127.0.0.1")}, [16]) = 4 recvfrom(4, "GET /favicon.ico HTTP/1.1\r\nHost:"..., 4096, 0, NULL, NULL) = 584 write(1, "Treating URI : /favicon.ico\n", 28Treating URI : /favicon.ico ) = 28
access("/home/michael/FPC/trunk/packages/fcl-web/examples/httpserver/favicon.ico", F_OK) = -1 ENOENT (No such file or directory) sendto(4, "HTTP/1.1 404 Not Found\r\nStatus: "..., 67, 0, NULL, 0) = 67 close(4) = 0
accept(3, {sa_family=AF_INET, sin_port=htons(59847), sin_addr=inet_addr("127.0.0.1")}, [16]) = 4 recvfrom(4, "GET /favicon.ico HTTP/1.1\r\nHost:"..., 4096, 0, NULL, NULL) = 614 write(1, "Treating URI : /favicon.ico\n", 28Treating URI : /favicon.ico ) = 28
access("/home/michael/FPC/trunk/packages/fcl-web/examples/httpserver/favicon.ico", F_OK) = -1 ENOENT (No such file or directory) sendto(4, "HTTP/1.1 404 Not Found\r\nStatus: "..., 67, 0, NULL, 0) = 67 close(4) = 0
accept(3,

Michael.

Reply by email

Jansen, Dirk
to Michael Van Canneyt
Show quoted text 9 lines
On Wed, 17 Jul 2013, Jansen, Dirk wrote: >>> I tested a simple http application and found that the > THTTPApplication >>> does not close the connection. >>> >>> A normal web server always close the connection after sending the > HTML >> page but this webserver does not close the connection. As a result

of

Show quoted text 16 lines
>> this every second request from a web browser (Firefox, IE) does not >> work. The browser starts the request than it waits for a very long > time. >> If you interrupt the browser and start a new request you get an > answer. > >> That is not correct. > >> In HTTP 1.1 The browser sends a HTTP header which determines if the > connection should be closed or not. > >> Secondly, THTTPApplication is an apache module. There it is apache > which determines what happens to the >> connection, not the FPC code. > > The THTTPApplication is part of the standalone "HTTP server

Application"

Show quoted text 7 lines
> (default project) of the weblazextra package. There is no apache > server involved. > > There is no difference if I user http 1.0, http 1.1 or if I set > "Connection: close". > > It is also impossible to send a second request over the open

connection.

I have tested, and a strace shows that the connection is always

closed:

Yes. My first test with telnet war not OK I think.

But if I try to Access the example server from firefox (http://localhost:8080:/index.html) I get the website. If I press F5 (Refresh) the request never ends.
If I press F5 again I get the Website.
If I press F5 again I the request never ends.
If I press F5 again I get the Website.
And so on.

Dirk

Reply by email