/[jscoverage]/trunk/jscoverage-server.c
ViewVC logotype

Diff of /trunk/jscoverage-server.c

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

revision 447 by siliconforks, Sun Aug 9 16:21:27 2009 UTC revision 480 by siliconforks, Thu Oct 8 20:53:51 2009 UTC
# Line 398  Line 398 
398    }    }
399  }  }
400    
401  static bool should_instrument_request(HTTPExchange * exchange) {  static bool should_instrument_request(HTTPExchange * exchange, const char * uri) {
402    if (! is_javascript(exchange)) {    if (! is_javascript(exchange)) {
403      return false;      return false;
404    }    }
405    
406    if (is_no_instrument(HTTPExchange_get_request_uri(exchange))) {    if (is_no_instrument(uri)) {
407      return false;      return false;
408    }    }
409    
# Line 801  Line 801 
801    
802    /* create a new exchange */    /* create a new exchange */
803    server_exchange = HTTPExchange_new(server_connection);    server_exchange = HTTPExchange_new(server_connection);
804    
805    HTTPExchange_set_method(server_exchange, HTTPExchange_get_method(client_exchange));    HTTPExchange_set_method(server_exchange, HTTPExchange_get_method(client_exchange));
806    HTTPExchange_set_request_uri(server_exchange, HTTPExchange_get_request_uri(client_exchange));  
807      /* don't send full URI to origin server - just send abs_path and query */
808      const char * query = HTTPExchange_get_query(client_exchange);
809      char * origin_server_request_uri;
810      if (query == NULL) {
811        origin_server_request_uri = xstrdup(abs_path);
812      }
813      else {
814        size_t abs_path_length = strlen(abs_path);
815        size_t query_length = strlen(query);
816        size_t origin_server_request_uri_length = addst(abs_path_length, query_length);
817        origin_server_request_uri_length = addst(origin_server_request_uri_length, 2);
818        origin_server_request_uri = xmalloc(origin_server_request_uri_length);
819        strcpy(origin_server_request_uri, abs_path);
820        origin_server_request_uri[abs_path_length] = '?';
821        strcpy(origin_server_request_uri + abs_path_length + 1, query);
822      }
823      HTTPExchange_set_request_uri(server_exchange, origin_server_request_uri);
824      free(origin_server_request_uri);
825    
826    for (const HTTPHeader * h = HTTPExchange_get_request_headers(client_exchange); h != NULL; h = h->next) {    for (const HTTPHeader * h = HTTPExchange_get_request_headers(client_exchange); h != NULL; h = h->next) {
827      if (strcasecmp(h->name, HTTP_TRAILER) == 0 || strcasecmp(h->name, HTTP_TRANSFER_ENCODING) == 0) {      if (strcasecmp(h->name, HTTP_TRAILER) == 0 || strcasecmp(h->name, HTTP_TRANSFER_ENCODING) == 0) {
828        /* do nothing: we want to keep this header */        /* do nothing: we want to keep this header */
# Line 845  Line 865 
865    
866    HTTPExchange_set_status_code(client_exchange, HTTPExchange_get_status_code(server_exchange));    HTTPExchange_set_status_code(client_exchange, HTTPExchange_get_status_code(server_exchange));
867    
868    if (HTTPExchange_response_has_body(server_exchange) && should_instrument_request(server_exchange)) {    if (HTTPExchange_response_has_body(server_exchange) && should_instrument_request(server_exchange, HTTPExchange_get_request_uri(client_exchange))) {
869      /* needs instrumentation */      /* needs instrumentation */
870      Stream * input_stream = Stream_new(0);      Stream * input_stream = Stream_new(0);
871      if (HTTPExchange_read_entire_response_entity_body(server_exchange, input_stream) != 0) {      if (HTTPExchange_read_entire_response_entity_body(server_exchange, input_stream) != 0) {
# Line 1240  Line 1260 
1260      fatal_command_line("--port: option must be 16 bits");      fatal_command_line("--port: option must be 16 bits");
1261    }    }
1262    
1263      /* check the document root exists and is a directory */
1264      struct stat buf;
1265      xstat(document_root, &buf);
1266      if (! S_ISDIR(buf.st_mode)) {
1267        fatal_command_line("--document-root: option must be a directory");
1268      }
1269    
1270    /* is this a shutdown? */    /* is this a shutdown? */
1271    if (shutdown) {    if (shutdown) {
1272  #ifdef __MINGW32__  #ifdef __MINGW32__

Legend:
Removed from v.447  
changed lines
  Added in v.480

  ViewVC Help
Powered by ViewVC 1.1.24