about http protocol and web server

Posted on 2003-02-22
Medium Priority
Last Modified: 2012-05-04
hi,i am making a simple web server and has several questions:

1)As requested by the problem,the web server need to process head method,which is somewhat similar to get method except the entity body.But if i use the internet explorer as a client testing tool.how it can send head method to test this function?

2)how the server can get and return the last modified time of a file using C/C++ since the server need to return this as a return header to the client,i thought there is no such method in their library?

3)how the server determine whether the client has the "cache" locally?as it appears in the return header:       cache:no/yes

4)what's the meaning of "Connection:close;" defined in the return header?And when a server need to return this header?

Your Help is greatly Appreciated!
Question by:yaoming
  • 3
  • 3

Expert Comment

ID: 7999972
1) You could use Telnet program if you need to see what will happen exactly. As I remember, HEAD method is identical to the GET method except that entity body is missing. It is used rarely and not required to be supported by any web server.

2) HTTP protocol operates with entities rather that FTP, which operates with files. As described in RFC-1945, there could be "Last-Modified" parameter in Entity-Header (likely after "Content-Type" parameter) as follows:
Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT

3) HTTP server could not determine if the client has a local cache because of the structure of HTTP protocol. Instead, server may provide cache-control directives. Note that this is not a rule that all clients will support them. HTTP 1.0 server could provide

Pragma: no-cache

directive to deny the client or proxy cache this page (see RFC-2068, section 14.32). HTTP 1.1 in addition to this defines a set of cache-control directives (see RFC-2068, section 14.9).

4) (Refer to the RFC-2068) HTTP/1.1 defines the "close" connection option for the sender to signal that the connection will be closed after completion of the response. For example,

Connection: close

in either the request or the response header fields indicates that the connection should not be considered `persistent' (section 8.1) after the current request/response is complete.

If you wish to learn more about HTTP protocol, you must obtain RFC-2068 (and RFC-1945) document which may be found (like another RFC's) at http://www.internic.net .

Good luck!

Expert Comment

ID: 7999988
Addition to section 2: What C/C++ libraries do you mean?

Author Comment

ID: 8000798
I just want to know whether there exists any method in C/C++ library that can get the last modified time of a file in a web server root.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8000851
hi,the circumtance when "Connection:close" and "cache:no"
are used seems clear to me. But can you tell me how the server got to know that circumtance happens?
for example, how the server/client know a connection is no longer persistent after the current request/response is complete?

Your help is greatly appreciated!


Accepted Solution

msa2003 earned 160 total points
ID: 8002491
I couldn't understand your question. Please be more clear. What circumtance do you mean?

When the client receives Connection: close directive it supposed that it will never try to close connection itself but it will wait the server to close connection. Allthrough the client may ignore Connection: close directive and close the connection just after it receives the final CRLF sequence. It is the only way how the server could tell the client who will terminate connection.

Pragma: no-cache is present when processing non-still data which could appear to change the next time the client will try to load this data. So, the server tells the client machine not to cache the instance it has to transfer. Allthrough the client could ignore this directive so if you really care about data freshness you coul use another tricks such as random-generated requests.

If you need to know about some C/C++ library function you need to specify what is the version of C/C++ compiler you are using. Borland C++ defines the function _dos_getftime(). MS VC++ should use Windows API function GetFileTime(), gcc has another one...

Author Comment

ID: 8002885
thanx ,i know what should be done with my server now.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question