Changeset 156 for uKadecot


Ignore:
Timestamp:
Feb 5, 2016, 9:06:37 AM (7 years ago)
Author:
coas-nagasima
Message:

クエリー式もリダイレクトアドレスに含めるよう修正

Location:
uKadecot/trunk
Files:
1 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • uKadecot/trunk/uip/apps/webserver/httpd.c

    r155 r156  
    107107        char headers[MAX(sizeof(http_header_404), sizeof(http_header_200))
    108108                + sizeof(http_content_encoding_gzip)
     109                + sizeof(http_location) + sizeof(((struct httpd_state *)0)->filename) + 2
    109110                + sizeof(union temp_type_t)
    110111        ];
     
    212213    len = strlen(s->filename);
    213214    memcpy(pos, s->filename, len); pos += len;
     215    if (s->query != NULL) {
     216      pos[0] = '?'; pos++;
     217      len = strlen(s->query);
     218      memcpy(pos, s->query, len); pos += len;
     219    }
    214220    len = 2;
    215221    memcpy(pos, "\r\n", len); pos += len;
    216222  }
    217223
    218   ptr = strrchr(s->message.request_url, ISO_period);
     224  ptr = strrchr(s->filename, ISO_period);
    219225  if (ptr == NULL) {
    220226    len = strlen(http_content_type_binary);
     
    418424  }
    419425
     426  ptr = strrchr(s->message.request_url, '?');
     427  if (ptr != NULL){
     428    ptr[0] = '\0';
     429    s->query = &ptr[1];
     430  }
     431  else
     432    s->query = NULL;
     433
    420434  /* ""か"/"なら"index.html"に変更 */
    421435  if ((s->message.request_url[0] == '\0') || ((s->message.request_url[0] == '/') && (s->message.request_url[1] == '\0'))) {
    422436    s->drv = 0;
    423437    strcpy_s(s->filename, sizeof(s->filename), http_index_html);
     438    s->file.redirect = 1;
    424439  }
    425440  /* "/~/"ならSDカードから読み込み */
     
    432447    strcpy_s(s->filename, sizeof(s->filename), s->message.request_url);
    433448  }
    434 
    435   ptr = strrchr(s->filename, '?');
    436   if (ptr != NULL)
    437     ptr[0] = '\0';
    438449
    439450  /*  httpd_log_file(uip_conn->ripaddr, s->message.request_url);*/
  • uKadecot/trunk/uip/apps/webserver/httpd.h

    r155 r156  
    6060      char filename[256];
    6161      int len;
     62      char *query;
    6263      struct httpd_fs_file file;
    6364    };
Note: See TracChangeset for help on using the changeset viewer.