Can I visit the URL by browser?
Closed this issue · 1 comments
After I start the httpd serve , I visit the URL http://127.0.1.1:8008/doc/index.html by FireFox.
And then the result I get was The connection was reset
My OS is Ubuntu 14
And here was all the info when I operate in terminal .
yisa@ubuntu32:~/httpd/tinyhttpd$ cd ./build/
yisa@ubuntu32:~/httpd/tinyhttpd/build$ cd .. && ./build/tinyhttpd &
[1] 3432
yisa@ubuntu32:~/httpd/tinyhttpd/build$ epfd: 4
[INFO] (/home/yisa/httpd/tinyhttpd/tinyhttpd.c:92: errno: None) "success to add fd: 3 into interest list."
tinyhttpd started successfully!
[INFO] (/home/yisa/httpd/tinyhttpd/tinyhttpd.c:112: errno: None) "ready fd: 3."
[INFO] (/home/yisa/httpd/tinyhttpd/tinyhttpd.c:130: errno: None) "success to accept a fd: 5."
[INFO] (/home/yisa/httpd/tinyhttpd/tinyhttpd.c:142: errno: None) "success to add fd: 5 into interest list."
[INFO] (/home/yisa/httpd/tinyhttpd/tinyhttpd.c:112: errno: Resource temporarily unavailable) "ready fd: 5."
[INFO] (/home/yisa/httpd/tinyhttpd/tinyhttpd.c:556: errno: Resource temporarily unavailable) "success to close fd: 5."
Hope for your help. Thank you
The reason why the client(browser) get error "connection reset by peer" is the server does not terminate the connection gracefully.
The file descriptor should not be closed at server side but should be closed by the client, therefore in HTTP response header, Content-length is needed to tell the client when to close the connection(fd).
You can refer to do_404() method to see the details of contents I have mentioned above.