| 19 | static const unsigned MAX_PARAMS = 16; |
| 20 | |
| 21 | void HttpParams::parseQuery(char* query) |
| 22 | { |
| 23 | clear(); |
| 24 | |
| 25 | if(query == nullptr) { |
| 26 | return; |
| 27 | } |
| 28 | // Accept query strings with or without '?' prefix |
| 29 | if(*query == '?') { |
| 30 | ++query; |
| 31 | } |
| 32 | |
| 33 | struct yuarel_param params[MAX_PARAMS]; |
| 34 | int paramCount = yuarel_parse_query(query, '&', params, MAX_PARAMS); |
| 35 | if(paramCount <= 0) { |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | if(!allocate(paramCount)) { |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | for(int i = 0; i < paramCount; ++i) { |
| 44 | String key = uri_unescape_inplace(params[i].key); |
| 45 | String value = uri_unescape_inplace(params[i].val); |
| 46 | operator[](key) = value; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | String HttpParams::toString() const |
| 51 | { |
no test coverage detected