Last active
August 29, 2015 14:11
-
-
Save pjz/166b28ef0b7b2b782cf2 to your computer and use it in GitHub Desktop.
lwip httpclientfetch url hack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static char* ICACHE_FLASH_ATTR findUrlPathStart(char *url) { | |
int i = 7; // skip 'http://' | |
while (url[i] != '/') { i++; } | |
return &url[i]; | |
} | |
void ICACHE_FLASH_ATTR httpClientFetch(char *url, int retbufsz, void (*cb)(char*)) { | |
static struct espconn conn; | |
static ip_addr_t ip; | |
char *hcserver = url[7]; // skip 'http://' | |
char *hcloc = findUrlPathStart(url); | |
callback=cb; | |
os_sprintf(hdr, "GET %s HTTP/1.1\r\n", hcloc); | |
hcloc[0] = '\0'; // terminate the server-string | |
os_sprintf(hdr, "Host: %s\r\nConnection: close\r\n\r\n", hcserver); | |
os_printf("httpclient: %s", hdr); | |
espconn_gethostbyname(&conn, hcserver, &ip, httpServerFoundCb); | |
hcloc[0] = '/'; // un-terminate the server-string | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment