On Sat, 16 Jul 2011 01:01:20 -0700 "Enlightenment SVN" <no-re...@enlightenment.org> wrote:
> Log: > clean up ecore-con server example: HTTP requires a seperator (\r\n in this > case) following each header line and a double separator between headers and > body. additionally, content-length must be EXACTLY the length of the body, > and must not include trailing garbage. snprintf use here is incorrect due to > inconsistent behavior of snprintf, so we can lazily fall back to strlen since > this is just a simple example > > Author: discomfitor > Date: 2011-07-16 01:01:19 -0700 (Sat, 16 Jul 2011) > New Revision: 61421 > Trac: http://trac.enlightenment.org/e/changeset/61421 > > Modified: > trunk/ecore/src/examples/ecore_con_server_http_example.c > > Modified: trunk/ecore/src/examples/ecore_con_server_http_example.c > =================================================================== > --- trunk/ecore/src/examples/ecore_con_server_http_example.c > 2011-07-16 07:38:33 UTC (rev 61420) +++ > trunk/ecore/src/examples/ecore_con_server_http_example.c 2011-07-16 > 08:01:19 UTC (rev 61421) @@ -14,11 +14,10 @@ "Server: Ecore_Con custom > server\r\n" "Content-Length: %zd\r\n" > "Content-Type: text/html; charset=UTF-8\r\n" > -"Set-Cookie: MYCOOKIE=1; path=/; expires=%s" > +"Set-Cookie: MYCOOKIE=1; path=/; expires=%s\r\n" > "Set-Cookie: SESSIONCOOKIE=1; path=/\r\n" technically using the set-cookie header twice like this is totally invalid too, but I ain't no babysitter > "\r\n" > -"%s" > -"\r\n\r\n"; > +"%s"; > > struct _Client { > int sdata; > @@ -31,7 +30,6 @@ > client->sdata = 0; > static char buf[4096]; > char welcome[] = "Welcome to Ecore_Con server!"; > - int nbytes; > time_t t; > > printf("Client with ip %s, port %d, connected = %d!\n", > @@ -43,9 +41,9 @@ > > t = time(NULL); > t += 60 * 60 * 24; > - nbytes = snprintf(buf, sizeof(buf), response_template, sizeof(welcome), > ctime(&t), welcome); > + snprintf(buf, sizeof(buf), response_template, sizeof(welcome) - 1, > ctime(&t), welcome); > - ecore_con_client_send(ev->client, buf, nbytes); > + ecore_con_client_send(ev->client, buf, strlen(buf)); > ecore_con_client_flush(ev->client); > > > > -- Mike Blumenkrantz Zentific: Coding in binary since '10. ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel