@Radon
2014-12-24T18:07:40.000000Z
字数 1487
阅读 1814
1100012749
| Request | Block size (decimal bytes) | Block header (hex) |
|---|---|---|
| malloc(3) | 8 | 0x9 |
| malloc(11) | 16 | 0x11 |
| malloc(20) | 24 | 0x19 |
| malloc(21) | 32 | 0x21 |
都是16
static char * cur = heap_listp;static void *find_fit(size_t asize) {/* Next fit search */void *bp = cur;while(GET_ALLOC(HDRP(bp)) || GET_SIZE(HDRP(bp)) < asize) {bp = (GET_SIZE(HDRP(bp)) == 0) ? heap_listp : NEXT_BLKP(bp);if (bp == cur) return NULL;}cur = NEXT_BLKP(bp);return bp;}
A.
void doit(int fd)中,sscanf(buf, "%s %s %s", method, uri, version);下加printf("%s %s %s\n", method, uri, version);
read_requesthdrs(rio_t *rp)按如下修改:
void read_requesthdrs(rio_t *rp){char buf[MAXLINE];do{Rio_readlineb(rp, buf, MAXLINE);printf("%s", buf);}while(strcmp(buf, "\r\n"));return;}
B.
GET / HTTP/1.1Host: localhost:12345User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:32.0) Gecko/20100101 Firefox/32.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateConnection: keep-aliveCache-Control: max-age=0
C. HTTP/1.1
D.
User-Agent: 标识生成请求的浏览器或其他客户程序
Accept: 浏览器或者其他客户程序能处理的MIME类型
Accept-Encoding: 可以接受的编码方案
Accept-Language: 可以接受的语言;
void get_filetype(char *filename, char *filetype){if (strstr(filename, ".html"))strcpy(filetype, "text/html");else if (strstr(filename, ".gif"))strcpy(filetype, "image/gif");else if (strstr(filename, ".jpg"))strcpy(filetype, "image/jpeg");else if(strstr(filename, ".mpg") || strstr(filename, ".mp4"))strcpy(filetype, "video/mpeg");elsestrcpy(filetype, "text/plain");}