simple_httpd.c (133836) | simple_httpd.c (189936) |
---|---|
1/*- 2 * Simple_HTTPd v1.1 - a very small, barebones HTTP server 3 * 4 * Copyright (c) 1998-1999 Marc Nicholas <marc@netstor.com> 5 * All rights reserved. 6 * 7 * Major rewrite by William Lloyd <wlloyd@slap.net> 8 * --- 13 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * | 1/*- 2 * Simple_HTTPd v1.1 - a very small, barebones HTTP server 3 * 4 * Copyright (c) 1998-1999 Marc Nicholas <marc@netstor.com> 5 * All rights reserved. 6 * 7 * Major rewrite by William Lloyd <wlloyd@slap.net> 8 * --- 13 unchanged lines hidden (view full) --- 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * |
30 * $FreeBSD: head/release/picobsd/tinyware/simple_httpd/simple_httpd.c 133836 2004-08-16 09:38:34Z dwmalone $ | 30 * $FreeBSD: head/release/picobsd/tinyware/simple_httpd/simple_httpd.c 189936 2009-03-17 19:51:04Z dwmalone $ |
31 */ 32 33#include <sys/stat.h> 34#include <sys/time.h> 35#include <sys/types.h> 36#include <sys/socket.h> 37#include <sys/wait.h> 38#include <netinet/in.h> 39#include <arpa/inet.h> 40 41#include <fcntl.h> 42#include <netdb.h> 43#include <signal.h> 44#include <stdio.h> | 31 */ 32 33#include <sys/stat.h> 34#include <sys/time.h> 35#include <sys/types.h> 36#include <sys/socket.h> 37#include <sys/wait.h> 38#include <netinet/in.h> 39#include <arpa/inet.h> 40 41#include <fcntl.h> 42#include <netdb.h> 43#include <signal.h> 44#include <stdio.h> |
45#include <stdint.h> |
|
45#include <stdlib.h> 46#include <string.h> 47#include <time.h> 48#include <unistd.h> 49 50int http_port = 80; 51int daemonize = 1; 52int verbose = 0; --- 220 unchanged lines hidden (view full) --- 273 if (seteuid(file_status.st_uid)) return; 274 if (!fork()) 275 { 276 close(1); 277 dup(con_sock); 278 /*printf("HTTP/1.0 200 OK\nContent-type: text/html\n\n\n");*/ 279 printf("HTTP/1.0 200 OK\r\n"); 280 /* Plug in environment variable, others in log_line */ | 46#include <stdlib.h> 47#include <string.h> 48#include <time.h> 49#include <unistd.h> 50 51int http_port = 80; 52int daemonize = 1; 53int verbose = 0; --- 220 unchanged lines hidden (view full) --- 274 if (seteuid(file_status.st_uid)) return; 275 if (!fork()) 276 { 277 close(1); 278 dup(con_sock); 279 /*printf("HTTP/1.0 200 OK\nContent-type: text/html\n\n\n");*/ 280 printf("HTTP/1.0 200 OK\r\n"); 281 /* Plug in environment variable, others in log_line */ |
281 putenv("SERVER_SOFTWARE=FreeBSD/PicoBSD"); | 282 setenv("SERVER_SOFTWARE", "FreeBSD/PicoBSD", 1); |
282 283 execlp (filename,filename,par,(char *)0); 284 } 285 wait(&i); 286 return; 287 } 288 conti: 289 if (filename == NULL) { --- 36 unchanged lines hidden (view full) --- 326 } 327 328 /* Past this point we are serving either a GET or HEAD */ 329 /* Print all the header info */ 330 http_output(http_200); 331 http_output(httpd_server_ident); 332 http_date(); 333 | 283 284 execlp (filename,filename,par,(char *)0); 285 } 286 wait(&i); 287 return; 288 } 289 conti: 290 if (filename == NULL) { --- 36 unchanged lines hidden (view full) --- 327 } 328 329 /* Past this point we are serving either a GET or HEAD */ 330 /* Print all the header info */ 331 http_output(http_200); 332 http_output(httpd_server_ident); 333 http_date(); 334 |
334 sprintf(buff, "Content-length: %lld\r\n", file_status.st_size); | 335 sprintf(buff, "Content-length: %jd\r\n", (intmax_t)file_status.st_size); |
335 write(con_sock, buff, strlen(buff)); 336 337 strcpy(buff, "Content-type: "); 338 type = default_mime_type; 339 if ((ext = strrchr(filename, '.')) != NULL) { 340 for (i = mime_type_max; i >= 0; i--) 341 if (strcmp(ext + 1, mime_type[i][0]) == 0) { 342 type = mime_type[i][1]; --- 157 unchanged lines hidden --- | 336 write(con_sock, buff, strlen(buff)); 337 338 strcpy(buff, "Content-type: "); 339 type = default_mime_type; 340 if ((ext = strrchr(filename, '.')) != NULL) { 341 for (i = mime_type_max; i >= 0; i--) 342 if (strcmp(ext + 1, mime_type[i][0]) == 0) { 343 type = mime_type[i][1]; --- 157 unchanged lines hidden --- |