diff options
Diffstat (limited to 'libnet')
-rw-r--r-- | libnet/http.c | 22 | ||||
-rw-r--r-- | libnet/inc/http.h | 3 |
2 files changed, 24 insertions, 1 deletions
diff --git a/libnet/http.c b/libnet/http.c index 8cd0f31..96dcd4d 100644 --- a/libnet/http.c +++ b/libnet/http.c @@ -65,3 +65,25 @@ char *http_query_get(const char *url, const char *path) strcat(query, "\r\n\r\n"); return query; } + +char *http_query_path(const char *query, char *path) +{ + u8 b = 0; + u32 s = 0; + u32 e = 0; + + while (1) { + if (!b && query[e] == ' ' && query[++e]) { + s = e; + b = 1; + } else if (b && query[e] == ' ') { + strncat(path, &query[s], e - s); + break; + } else if (query[e] == '\0') { + return NULL; + } + e++; + } + + return path; +} diff --git a/libnet/inc/http.h b/libnet/inc/http.h index 559ea3d..223bdfc 100644 --- a/libnet/inc/http.h +++ b/libnet/inc/http.h @@ -6,9 +6,10 @@ #include <def.h> char *http_data(char *response); +char *http_code(char *r); u32 http_response(const char *http_code, u32 content_length, const char *data, char *resp); char *http_query_get(const char *url, const char *path); -char *http_code(char *r); +char *http_query_path(const char *query, char *path); #define HTTP_100 "100 Continue" #define HTTP_101 "101 Switching Protocol" |