Enlightenment CVS committal Author : sebastid Project : e17 Module : apps/e_modules
Dir : e17/apps/e_modules/src/modules/weather Modified Files: e_mod_main.c e_mod_main.h Log Message: Handle proxy env =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e_modules/src/modules/weather/e_mod_main.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- e_mod_main.c 24 Aug 2005 22:52:27 -0000 1.16 +++ e_mod_main.c 25 Aug 2005 11:11:44 -0000 1.17 @@ -707,6 +707,41 @@ static void _weather_connect(Weather *weather) { + char *env; + + env = getenv("HTTP_PROXY"); + if (!env) + env = getenv("http_proxy"); + if ((env) && !strncmp(env, "http://", 7)) + { + /* Use a proxy */ + char *host = NULL, *p; + int port = 0; + + host = strchr(env, ':'); + host += 3; + p = strchr(host, ':'); + if (p) + { + *p = 0; + p++; + if (sscanf(p, "%d", &port) != 1) + port = 0; + } +#if 0 + else + { + p = strchr(host, '/'); + if (p) + *p = 0; + } +#endif + if ((host) && (port)) + { + weather->proxy.host = strdup(host); + weather->proxy.port = port; + } + } weather->add_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, _weather_net_server_add, weather); weather->del_handler = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, @@ -733,8 +768,16 @@ face->cursize = 0; face->buffer = malloc(face->bufsize); face->buffer[0] = 0; - face->server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, - weather->conf->host, 80, face); + if (weather->proxy.port) + { + face->server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, + weather->proxy.host, weather->proxy.port, face); + } + else + { + face->server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM, + weather->conf->host, 80, face); + } } return 1; } @@ -759,7 +802,10 @@ } if ((!face) || (e->server != face->server)) return 1; - snprintf(buf, sizeof(buf), "GET %s HTTP/1.0\r\n\r\n", face->conf->url); + snprintf(buf, sizeof(buf), "GET http://%s%s HTTP/1.1\r\nHost: %s\r\n\r\n", + weather->conf->host, + face->conf->url, + weather->conf->host); ecore_con_server_send(face->server, buf, strlen(buf)); return 1; } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e_modules/src/modules/weather/e_mod_main.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- e_mod_main.h 14 Aug 2005 21:53:57 -0000 1.5 +++ e_mod_main.h 25 Aug 2005 11:11:44 -0000 1.6 @@ -51,6 +51,11 @@ Config *conf; Ecore_Timer *weather_check_timer; + + struct { + char *host; + int port; + } proxy; }; struct _Weather_Face ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs