cs531-f19 / discussions

Discussions board for CS 431/531 Web Server Design course
2 stars 12 forks source link

Requests to 500.cgi #74

Open ghost opened 4 years ago

ghost commented 4 years ago

Through the tests and it's naming, I understand that the cgi script /a5-test/500.cgi is intended to cause a 500 Internal Server Error response. I am uncertain as to what about the script is supposed to lead to this response though. The permissions have x and r, the perl is entirely valid and it does not seem to give "malformed output".

What am I missing?

ibnesayeed commented 4 years ago

I think you did not attend the CGI lecture and when we revisited it last week. A CGI script must contain at least one header/status line. The full detains of what is optional and what is inferred in certain situations can be read in the RFC 3875. There are some examples to highlight some scenarios in the lecture slides. The 500.cgi script generates file listing, but it should have at least the Content-type header in it and a blank line before the entity body starts (if the commented line in the script was uncommented, it will become a valid CGi script).

6.2.  Response Types

   The response comprises a message-header and a message-body, separated
   by a blank line.  The message-header contains one or more header
   fields.  The body may be NULL.

      generic-response = 1*header-field NL [ response-body ]
6.3.1.  Content-Type

   The Content-Type response field sets the Internet Media Type [6] of
   the entity body.

      Content-Type = "Content-Type:" media-type NL

   If an entity body is returned, the script MUST supply a Content-Type
   field in the response.  If it fails to do so, the server SHOULD NOT
   attempt to determine the correct content type.  The value SHOULD be
   sent unmodified to the client, except for any charset parameter
   changes.