/[monit]/monit/http/processor.c
ViewVC logotype

Diff of /monit/http/processor.c

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

revision 1.23 by hauk, Fri Sep 19 03:44:17 2003 UTC revision 1.24 by hauk, Fri Sep 19 04:49:36 2003 UTC
# Line 93  Line 93 
93   *    found in the URL it's asumed to be the PATHINFO. In other words   *    found in the URL it's asumed to be the PATHINFO. In other words
94   *    this processor perceive an URL as:   *    this processor perceive an URL as:
95   *   *
96   *                      /COMMAND?args/PATHINFO   *                      /COMMAND?QUERYSTRING/PATHINFO
97   *   *
98   *     The doGet/doPost routines act's on the COMMAND. See the   *     The doGet/doPost routines act's on the COMMAND. See the
99   *     cervlet.c code in this dir. for an example.   *     cervlet.c code in this dir. for an example.
# Line 135  static int is_authenticated(HttpRequest, Line 135  static int is_authenticated(HttpRequest,
135  /**  /**
136   * Process a HTTP request. This is done by dispatching to the service   * Process a HTTP request. This is done by dispatching to the service
137   * function.   * function.
138   * @param s A Socket_T object wrapping the client socket connection   * @param s A Socket_T representing the client connection
139   */   */
140  void *http_processor(void *s) {  void *http_processor(void *s) {
141        
# Line 213  void send_redirect(HttpResponse res, con Line 213  void send_redirect(HttpResponse res, con
213   * actual response to the client is done in the service function,   * actual response to the client is done in the service function,
214   * which will call the private function send_response.  Cervlets   * which will call the private function send_response.  Cervlets
215   * should use this function (i.e. out_print) for sending a response,   * should use this function (i.e. out_print) for sending a response,
216   * and never use the HttpResponse outputstream directly.   * and never use the HttpResponse Socket directly to send data.
217   *   *
218   * Despite the above warning, IF the HttpResponse.outputstream was   * Despite the above warning, IF the HttpResponse.socket was used
219   * used directly by a cervlet THEN the cervlet MUST set the   * directly by a cervlet THEN the cervlet MUST set the is_committed
220   * is_committed flag in the HttpResponse object and is responsible for   * flag in the HttpResponse object and is responsible for sending all
221   * sending all HTTP headers and content by itself.   * HTTP headers and content by itself.
222   * @param res HttpResponse object   * @param res HttpResponse object
223   * @param m A formated string to be sent to the client   * @param m A formated string to be sent to the client
224   */   */
# Line 396  char *get_headers(HttpResponse res) { Line 396  char *get_headers(HttpResponse res) {
396    
397    *buf=0;    *buf=0;
398        
399    for(p= res->headers; p && ((b-buf)>RES_STRLEN); p= p->next) {    for(p= res->headers; p; p= p->next) {
400            
401      b+= snprintf(b, STRLEN-(b-buf),"%s: %s\r\n", p->name, p->value);      b+= snprintf(b, STRLEN-(b-buf),"%s: %s\r\n", p->name, p->value);
402            
# Line 519  static void do_service(Socket_T s) { Line 519  static void do_service(Socket_T s) {
519    
520      if(is_authenticated(req, res)) {      if(is_authenticated(req, res)) {
521                
522        if(!strcmp(req->method, METHOD_GET)) {        if(IS(req->method, METHOD_GET)) {
523    
524          Impl.doGet(req, res);          Impl.doGet(req, res);
525                    
526        }        }
527        else if(!strcmp(req->method, METHOD_POST)) {        else if(IS(req->method, METHOD_POST)) {
528    
529          Impl.doPost(req, res);          Impl.doPost(req, res);
530                    
# Line 587  static void send_response(HttpResponse r Line 587  static void send_response(HttpResponse r
587    Socket_T S= res->S;    Socket_T S= res->S;
588    
589    if(!res->is_committed) {    if(!res->is_committed) {
590        
591      char date[STRLEN];      char date[STRLEN];
592      char server[STRLEN];      char server[STRLEN];
593      char *headers= get_headers(res);      char *headers= get_headers(res);
# Line 670  static HttpRequest create_HttpRequest(So Line 671  static HttpRequest create_HttpRequest(So
671    
672  /**  /**
673   * Returns a new HttpResponse object wrapping a default response. Use   * Returns a new HttpResponse object wrapping a default response. Use
674   * set_XXX methods to change the object.   * the set_XXX methods to change the object.
675   */   */
676  static HttpResponse create_HttpResponse(Socket_T S) {  static HttpResponse create_HttpResponse(Socket_T S) {
677        
# Line 709  static void create_headers(HttpRequest r Line 710  static void create_headers(HttpRequest r
710      if(! socket_readln(S, line, sizeof(line)))      if(! socket_readln(S, line, sizeof(line)))
711          break;          break;
712    
713      if(!strcmp(line, "\r\n") || !strcmp(line, "\n"))      if(IS(line, "\r\n") || IS(line, "\n"))
714          break;          break;
715            
716      if( NULL != (value= strchr(line, ':'))) {      if( NULL != (value= strchr(line, ':'))) {
# Line 750  static int create_parameters(HttpRequest Line 751  static int create_parameters(HttpRequest
751    int alloc= FALSE;    int alloc= FALSE;
752    char *query_string= NULL;    char *query_string= NULL;
753    
754    if(!strcmp(req->method, METHOD_POST)) {    if(IS(req->method, METHOD_POST)) {
755    
756      Socket_T S= req->S;      Socket_T S= req->S;
757            
# Line 771  static int create_parameters(HttpRequest Line 772  static int create_parameters(HttpRequest
772                
773      }      }
774            
775    } else if(!strcmp(req->method, METHOD_GET)) {    } else if(IS(req->method, METHOD_GET)) {
776            
777      char *p;      char *p;
778            
# Line 817  static void reset_response(HttpResponse Line 818  static void reset_response(HttpResponse
818    
819    if(res->headers)destroy_entry(res->headers);    if(res->headers)destroy_entry(res->headers);
820    memset(res->outputbuffer, 0, res->bufsize);    memset(res->outputbuffer, 0, res->bufsize);
821      res->bufused= 0;
822    res->headers= NULL; /* Release Pragma */    res->headers= NULL; /* Release Pragma */
823        
824  }  }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26