Diff

Differences From Artifact [3d68b06497]:

To Artifact [602946c512]:


555
556
557
558
559
560
561

562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578




579
580
581
582
583
584
585
555
556
557
558
559
560
561
562
563
564
565

566
567


568
569
570
571
572
573
574
575

576
577
578
579
580
581
582
583
584
585
586







+



-


-
-








-
+
+
+
+







	return(buffer);
}

/* Process an HTTP request and return the path requested */
static struct filed_http_request *filed_get_http_request(FILE *fp, struct filed_http_request *buffer_st) {
	char *method, *path;
	char *buffer, *workbuffer, *workbuffer_next;
	char *fgets_ret;
	size_t buffer_len;
	off_t range_start, range_end, range_length;
	int range_request;
	int fd;
	int i;

	fd = fileno(fp);

	range_start = 0;
	range_end   = 0;
	range_request = 0;
	range_length = -1;

	buffer = buffer_st->tmpbuf;
	buffer_len = sizeof(buffer_st->tmpbuf);

	fgets(buffer, buffer_len, fp);
	fgets_ret = fgets(buffer, buffer_len, fp);
	if (fgets_ret == NULL) {
		return(NULL);
	}

	method = buffer;

	buffer = strchr(buffer, ' ');
	if (buffer == NULL) {
		return(NULL);
	}
602
603
604
605
606
607
608



609
610
611
612
613
614
615
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619







+
+
+








	/* Note path */
	strcpy(buffer_st->path, path);

	for (i = 0; i < 100; i++) {
		buffer = buffer_st->tmpbuf;
		fgets(buffer, buffer_len, fp);
		if (fgets_ret == NULL) {
			break;
		}

		if (strncasecmp(buffer, "Range: ", 7) == 0) {
			workbuffer = buffer + 7;

			if (strncasecmp(workbuffer, "bytes=", 6) == 0) {
				workbuffer += 6;

651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
655
656
657
658
659
660
661



662
663
664
665
666
667
668







-
-
-








	/* Fill up structure to return */
	buffer_st->headers.range.present = range_request;
	buffer_st->headers.range.offset  = range_start;
	buffer_st->headers.range.length  = range_length;

	return(buffer_st);

	/* Make compiler happy */
	fd = fd;
}

/* Return an error page */
static void filed_error_page(FILE *fp, const char *date_current, int error_number) {
	char *error_string = "<html><head><title>ERROR</title></head><body>Unable to process request</body></html>";

	fprintf(fp, "HTTP/1.1 %i Not OK\r\nDate: %s\r\nServer: filed\r\nLast-Modified: %s\r\nContent-Length: %llu\r\nContent-Type: %s\r\nConnection: close\r\n\r\n%s",