Add support for http:// urls

This commit is contained in:
Nick Krichevsky 2018-09-02 21:13:51 -04:00
parent 28f5448b49
commit 31a19298c3
2 changed files with 5 additions and 0 deletions

View file

@ -53,6 +53,10 @@ int main(int argc, char* argv[]) {
* @param host_buffer A buffer large enough to hold the host of the dest
*/
void get_parts(const char *dest, char *path_buffer, char *host_buffer) {
// If the destination starts with PROTO_PREFIX, skip it
if (strstr(dest, PROTO_PREFIX) == dest) {
dest += strlen(PROTO_PREFIX);
}
const char *slash_cursor;
for (slash_cursor = dest; *slash_cursor != '\0' && *slash_cursor != '/'; slash_cursor++);

View file

@ -4,6 +4,7 @@
#define RTT_FLAG "-p"
#define USAGE_STRING "Usage: ./http_client [-p] server_url port_number\n"
#define PORT_ERROR "Port must be a number in the range 1-65535"
#define PROTO_PREFIX "http://"
void get_parts(const char *dest, char *path_buffer, char *host_buffer);