/[hydra]/hydra/src/response.c
ViewVC logotype

Diff of /hydra/src/response.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by nmav, Sat Sep 21 13:53:24 2002 UTC revision 1.2 by nmav, Sun Sep 22 09:07:57 2002 UTC
# Line 36  void print_content_type(request * req) Line 36  void print_content_type(request * req)
36    
37  void print_content_length(request * req)  void print_content_length(request * req)
38  {  {
39    char buf[22];
40        
41        simple_itoa(req->filesize, buf);
42      req_write(req, "Content-Length: ");      req_write(req, "Content-Length: ");
43      req_write(req, simple_itoa(req->filesize));      req_write(req, buf);
44      req_write(req, "\r\n");      req_write(req, "\r\n");
45  }  }
46    
47  void print_last_modified(request * req)  void print_last_modified(request * req)
48  {  {
49      static char lm[] = "Last-Modified: "      char lm[] = "Last-Modified: "
50          "                             " "\r\n";          "                             " "\r\n";
51      rfc822_time_buf(lm + 15, req->last_modified);      rfc822_time_buf(lm + 15, req->last_modified);
52      req_write(req, lm);      req_write(req, lm);
# Line 51  void print_last_modified(request * req) Line 54  void print_last_modified(request * req)
54    
55  void print_ka_phrase(request * req)  void print_ka_phrase(request * req)
56  {  {
57    
58      if (req->kacount > 0 &&      if (req->kacount > 0 &&
59          req->keepalive == KA_ACTIVE && req->response_status < 500) {          req->keepalive == KA_ACTIVE && req->response_status < 500) {
60            char buf[22];
61          req_write(req, "Connection: Keep-Alive\r\nKeep-Alive: timeout=");          req_write(req, "Connection: Keep-Alive\r\nKeep-Alive: timeout=");
62          req_write(req, simple_itoa(ka_timeout));          simple_itoa(ka_timeout, buf);
63            req_write(req, buf);
64          req_write(req, ", max=");          req_write(req, ", max=");
65          req_write(req, simple_itoa(req->kacount));          simple_itoa(req->kacount, buf);
66            req_write(req, buf);
67          req_write(req, "\r\n");          req_write(req, "\r\n");
68      } else      } else
69          req_write(req, "Connection: close\r\n");          req_write(req, "Connection: close\r\n");
# Line 66  extern char * version; Line 73  extern char * version;
73    
74  void print_http_headers(request * req)  void print_http_headers(request * req)
75  {  {
76      static char date_stuff[] = "Date: "      char date_stuff[] = "Date: "
77          "                             "          "                             "
78          "\r\n";          "\r\n";
79                    
# Line 321  void send_r_bad_gateway(request * req) Line 328  void send_r_bad_gateway(request * req)
328  /* R_SERVICE_UNAVAILABLE: 503 */  /* R_SERVICE_UNAVAILABLE: 503 */
329  void send_r_service_unavailable(request * req) /* 503 */  void send_r_service_unavailable(request * req) /* 503 */
330  {  {
331      static char body[] =      static const char body[] =
332          "<HTML><HEAD><TITLE>503 Service Unavailable</TITLE></HEAD>\n"          "<HTML><HEAD><TITLE>503 Service Unavailable</TITLE></HEAD>\n"
333          "<BODY><H1>503 Service Unavailable</H1>\n"          "<BODY><H1>503 Service Unavailable</H1>\n"
334          "There are too many connections in use right now.\r\n"          "There are too many connections in use right now.\r\n"
335          "Please try again later.\r\n</BODY></HTML>\n";          "Please try again later.\r\n</BODY></HTML>\n";
336      static int _body_len;      static int _body_len;
337      static char *body_len;      static char body_len[22];
338    
339      if (!_body_len)      if (!_body_len)
340          _body_len = strlen(body);          _body_len = strlen(body);
341      if (!body_len)      if (!body_len[0])
342          body_len = strdup(simple_itoa(_body_len));          simple_itoa( _body_len, body_len);
     if (!body_len) {  
         log_error_time();  
         perror("strdup of _body_len from simple_itoa");  
     }  
   
343    
344      SQUASH_KA(req);      SQUASH_KA(req);
345      req->response_status = R_SERVICE_UNAV;      req->response_status = R_SERVICE_UNAV;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26