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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI


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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

777 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