/*----------------------------------------------------------------------*/ int get_url(char *url, FILE *outfile){ char *server; int port; char *path; int rc, s; rc = parse_url(url, &server, &port, &path); if(rc<0){ ERROR1("Problem with parsing url %s", url); } #ifdef DEBUG printf("http connection to %s:%d, path: %s\n", server, port, path); #endif s = call_socket(server, port); if(s==-1){ /* error msgs in call_socket */ return -1; } /* we can free memory for server string */ free(server); return get_http(s, path, outfile); }
int main(int argc, char *argv[]) { std::string zz = get_http("www.alhem.net", 80, "GET /index.html HTTP/1.0\r\n" "Host: www.alhem.net\r\n" "Connection: close\r\n" "\r\n"); printf("%s\n%d\n", zz.c_str(), zz.size()); }
String ota_get_latest_version() { // Get latest firmware version number String url = u_url; return get_http(u_host, url); }