An Embeddable HTTP Server
by M. Tim Jones

Example 1:
(a)

GET /index.html HTTP/1.1
Accept: text/html
Accept: image/gif
User-Agent:  Lynx/2.2
Host: www.myhost.mydomain
(* blank line *)

(b)

HTTP/1.1 200 OK
Server: NCSA/1.3
MIME-Version: 1.0
Content-Type: text/html
(* blank line *)
<HTML><HEAD><TITLE>A response</TITLE></HEAD>
<BODY>This is the index file</BODY>
</HTML>

Example 2:

/* filedata.c */
unsigned char filedata[]={

  /* File: /testfile, size 5 */
  0xfa, 0xf3, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x66, 0x69, 0x6c, 0x65, 0x00,
  0x00, 0x00, 0x00, 0x05, 0x41, 0x42, 0x43, 0x44, 0x0a,

  /* File: /file2, size 22 */
  0xfa, 0xf3, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x32, 0x00, 0x00, 0x00, 0x00,
  0x16, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x0a, 0x74,
  0x65, 0x73, 0x74, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x0a, 0x0a, 0x00,
  0x00, 0x00, 0x00
};


Example 3:

(a) 
addDynamicContent("temperature", &getTemperature); 

(b)

static char dyndata[81];
char *getTemperature(void)
{
	float temp;
	// read the temperature
	sprintf(dyndata, "%5.2f", temp);
	return(dyndata);
}




1

