|
Server 0.0.1
HTTP/REST server implementation
|
00001 00023 #include <string.h> 00024 #include <sys/types.h> 00025 00026 #include "http/parser.h" 00027 #include "http/request.h" 00028 #include "hash.h" 00029 #include "class.h" 00030 00036 void 00037 httpParserPostVars(HttpParser this) 00038 { 00039 HttpRequest request = (HttpRequest)this->current; 00040 char * pair = this->current->body; 00041 ssize_t togo = this->current->nbody; 00042 00043 while(NULL != pair && 0 < togo) { 00044 char * key = pair; 00045 char * eqsign = memchr(key, '=', togo); 00046 char * value; 00047 size_t nvalue; 00048 00049 if (NULL == eqsign) { 00050 return; 00051 } 00052 00053 togo -= (eqsign - key); 00054 pair = memchr(eqsign, '&', togo); 00055 00056 if (NULL == pair) { 00057 pair = &(this->current->body[this->current->nbody]); 00058 } 00059 00060 nvalue = pair-eqsign-1; 00061 value = (0 != nvalue)? eqsign+1 : NULL; 00062 00063 hashAdd(request->post, 00064 new(HashValue, key, eqsign-key, value, nvalue)); 00065 00066 pair++; 00067 togo -= (pair - eqsign); 00068 } 00069 } 00070 00071 // vim: set ts=4 sw=4: