📄 httpp.c,v
字号:
avl_delete(parser->vars, (void *)var, _free_vars); avl_insert(parser->vars, (void *)var); }d476 2a477 2 http_var_t var; http_var_t *found;d479 2a480 2 var.name = name; var.value = NULL;d482 4a485 4 if (avl_get_by_key(parser->vars, (void *)&var, (void **)&found) == 0) return found->value; else return NULL;d490 1a490 1 http_var_t *var;d492 2a493 2 if (name == NULL || value == NULL) return;d495 2a496 2 var = (http_var_t *)malloc(sizeof(http_var_t)); if (var == NULL) return;d498 9a506 9 var->name = strdup(name); var->value = url_escape(value); if (httpp_get_query_param(parser, name) == NULL) { avl_insert(parser->queryvars, (void *)var); } else { avl_delete(parser->queryvars, (void *)var, _free_vars); avl_insert(parser->queryvars, (void *)var); }d511 2a512 2 http_var_t var; http_var_t *found;d514 2a515 2 var.name = name; var.value = NULL;d517 4a520 4 if (avl_get_by_key(parser->queryvars, (void *)&var, (void **)&found) == 0) return found->value; else return NULL;d525 7a531 7 parser->req_type = httpp_req_none; if (parser->uri) free(parser->uri); parser->uri = NULL; avl_tree_free(parser->vars, _free_vars); avl_tree_free(parser->queryvars, _free_vars); parser->vars = NULL;d536 2a537 2 httpp_clear(parser); free(parser);d542 3a544 3 long i; for (i = 0; i < strlen(str); i++) str[i] = tolower(str[i]);d546 1a546 1 return str;d551 1a551 1 http_var_t *vara, *varb;d553 2a554 2 vara = (http_var_t *)a; varb = (http_var_t *)b;d556 1a556 1 return strcmp(vara->name, varb->name);d561 1a561 1 http_var_t *var;d563 1a563 1 var = (http_var_t *)key;d565 5a569 5 if (var->name) free(var->name); if (var->value) free(var->value); free(var);d571 1a571 1 return 1;@1.16log@include the automake config.h file if the application defines one@text@d16 1a16 1#include "avl.h"@1.15log@Set another parameter in the icy protocol parse that logging expects@text@d6 4@1.14log@Added support for shoutcast login protocol (ewww...)@text@d299 1@1.13log@Use gnu archive ACX_PTHREAD macro to figure out how to compile thread support.Also make it possible to build libshout without threads, albeit without lockingin the resolver or avl trees.New option --disable-pthread too.@text@d273 36d387 4a390 2 } else parser->uri = NULL;@1.12log@Fix some warnings, fix cflags.@text@a11 1#include "thread.h"@1.11log@Indentation again, don't mind me@text@d58 2a59 1 int i, lines = 0;@1.10log@Make indentation consistent before doing other work@text@d472 1a472 1 var.value = NULL;@1.9log@mp3 metadata complete. Still untested.@text@d43 1a43 1 parser->queryvars = avl_tree_new(_compare_vars, NULL);d122 4a125 4 char *data; char *line[MAX_HEADERS]; int lines, slen,i, whitespace=0, where=0,code; char *version=NULL, *resp_code=NULL, *message=NULL;d127 2a128 2 if(http_data == NULL) return 0;d134 1a134 1 data[len] = 0;d136 1a136 1 lines = split_headers(data, len, line);d138 20a157 22 /* In this case, the first line contains: * VERSION RESPONSE_CODE MESSAGE, such as * HTTP/1.0 200 OK */ slen = strlen(line[0]); version = line[0]; for(i=0; i < slen; i++) { if(line[0][i] == ' ') { line[0][i] = 0; whitespace = 1; } else if(whitespace) { whitespace = 0; where++; if(where == 1) resp_code = &line[0][i]; else { message = &line[0][i]; break; } } }d159 4a162 10 if(version == NULL || resp_code == NULL || message == NULL) { free(data); return 0; } httpp_setvar(parser, HTTPP_VAR_ERROR_CODE, resp_code); code = atoi(resp_code); if(code < 200 || code >= 300) { httpp_setvar(parser, HTTPP_VAR_ERROR_MESSAGE, message); }d164 7a170 1 httpp_setvar(parser, HTTPP_VAR_URI, uri);d173 1a173 1 parse_headers(parser, line, lines);d182 8a189 8 if(c >= '0' && c <= '9') return c - '0'; else if(c >= 'A' && c <= 'F') return c - 'A' + 10; else if(c >= 'a' && c <= 'f') return c - 'a' + 10; else return -1;d194 39a232 39 int len = strlen(src); unsigned char *decoded; int i; char *dst; int done = 0; decoded = calloc(1, len + 1); dst = decoded; for(i=0; i < len; i++) { switch(src[i]) { case '%': if(i+2 >= len) { free(decoded); return NULL; } if(hex(src[i+1]) == -1 || hex(src[i+2]) == -1 ) { free(decoded); return NULL; } *dst++ = hex(src[i+1]) * 16 + hex(src[i+2]); i+= 2; break; case '#': done = 1; break; case 0: free(decoded); return NULL; break; default: *dst++ = src[i]; break; } if(done) break; }d234 1a234 1 *dst = 0; /* null terminator */d236 1a236 1 return decoded;d242 29a270 30 int len; int i=0; char *key = query; char *val=NULL; if(!query || !*query) return; len = strlen(query); while(i<len) { switch(query[i]) { case '&': query[i] = 0; if(val && key) { httpp_set_query_param(parser, key, val); } key = query+i+1; break; case '=': query[i] = 0; val = query+i+1; break; } i++; } if(val && key) { httpp_set_query_param(parser, key, val); }d282 1a282 1 int whitespace, where, slen;d291 1a291 1 data[len] = 0;d293 1a293 1 lines = split_headers(data, len, line);d342 7a348 8 if (uri != NULL && strlen(uri) > 0) { char *query; if((query = strchr(uri, '?')) != NULL) { *query = 0; query++; parse_query(parser, query); }d351 1a351 2 } elsed396 1a396 1 if (parser->uri != NULL) {d403 1a403 1 parse_headers(parser, line, lines);d437 1a437 1 var.value = NULL;d493 2a494 2 httpp_clear(parser); free(parser);@1.8log@bugfixes for httpp_parse_response@text@d43 1d182 94d345 9a353 1 if (uri != NULL && strlen(uri) > 0)d355 1d442 1a442 1 var.value = NULL;d450 35d492 1@1.7log@Cleaned up version of Ciaran Anscomb's relaying patch.@text@d165 1a168 2 free(data); return 0;d172 1a172 1 httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "RELAY");@1.6log@Memory leaks. Lots of little ones.@text@d52 1a52 1int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len)a53 21 char *data, *tmp; char *line[MAX_HEADERS]; /* limited to 32 lines, should be more than enough */ int i, l, retlen; int lines; char *req_type = NULL; char *uri = NULL; char *version = NULL; char *name = NULL; char *value = NULL; int whitespace, where; int slen; if (http_data == NULL) return 0; /* make a local copy of the data, including 0 terminator */ data = (char *)malloc(len+1); if (data == NULL) return 0; memcpy(data, http_data, len); data[len] = 0;d57 1a57 1 lines = 0;d75 128a202 1 retlen = i;d298 1a298 1 if (parser->uri != NULL) {d305 1a305 31 /* parse the name: value lines. */ for (l = 1; l < lines; l++) { where = 0; whitespace = 0; name = line[l]; value = NULL; slen = strlen(line[l]); for (i = 0; i < slen; i++) { if (line[l][i] == ':') { whitespace = 1; line[l][i] = '\0'; } else { if (whitespace) { whitespace = 0; while (i < slen && line[l][i] == ' ') i++; if (i < slen) value = &line[l][i]; break; } } } if (name != NULL && value != NULL) { httpp_setvar(parser, _lowercase(name), value); name = NULL; value = NULL; } }d309 1a309 1 return retlen;@1.5log@Buffer overflows.Requires a change to the format plugin interface - jack: if you want thisdone differently, feel free to change it (or ask me to).@text@d271 1a271 1void httpp_destroy(http_parser_t *parser)d279 6@1.4log@Bunch of fixes: - connections are now matched to format plugins based on content-type headers, and are rejected if there isn't a format handler for that content-type, or there is no content-type at all. - format_vorbis now handles pages with granulepos of -1 in the headers correctly (this happens if the headers are fairly large, because of many comments, for example). - various #include fixes. - buffer overflow in httpp.c fixed.@text@d6 2d20 2d55 1a55 1 char *line[32]; /* limited to 32 lines, should be more than enough */d80 1a80 1 for (i = 0; i < len; i++) {@1.3log@Thanks to Akos Maroy <darkeye@@tyrell.hu> for this. These variables need tobe uppercase always in order to comply with the HTTP specification.While not a problem internal to icecast, they were slipping into the logfiles and breaking some less-than-robust parsers.@text@d65 2a66 2 /* make a local copy of the data */ data = (char *)malloc(len);d69 1d81 3a83 3 if (i + 1 < len) if (data[i + 1] == '\n' || data[i + 1] == '\r') { data[i] = '\0';a84 3 } data[i] = '\0'; if (i < len - 1)d86 1@1.2log@Win32 compatibility courtesy of Oddsock.@text@d150 1a150 1 httpp_setvar(parser, HTTPP_VAR_PROTOCOL, _lowercase(version));d164 1a164 1 httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "get");d167 1a167 1 httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "post");d170 1a170 1 httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "head");d173 1a173 1 httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "source");d176 1a176 1 httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "play");d179 1a179 1 httpp_setvar(parser, HTTPP_VAR_REQ_TYPE, "stats");@1.1log@Initial revision@text@d14 4d54 5a58 4 char *req_type; char *uri; char *version; char *name, *value;@1.1.1.1log@move to cvs@text@@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -