The R Project SVN R

Rev

Rev 51563 | Rev 51805 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51563 Rev 51653
Line 741... Line 741...
741
		    c->part = PART_REQUEST;
741
		    c->part = PART_REQUEST;
742
		    c->attr = 0;
742
		    c->attr = 0;
743
		    c->content_length = 0;
743
		    c->content_length = 0;
744
		    return;
744
		    return;
745
		}
745
		}
-
 
746
		/* copy body content (as far as available) */
-
 
747
		c->body_pos = (c->content_length < c->line_pos) ? c->content_length : c->line_pos;
-
 
748
		if (c->body_pos) {
-
 
749
		    memcpy(c->body, c->line_buf, c->body_pos);
-
 
750
		    c->line_pos -= c->body_pos; /* NOTE: we are NOT moving the buffer since non-zero left-over causes connection close */
-
 
751
		}
746
		/* POST will continue into the BODY part */
752
		/* POST will continue into the BODY part */
747
		break;
753
		break;
748
	    }
754
	    }
749
	    {
755
	    {
750
		char *bol = s;
756
		char *bol = s;
Line 824... Line 830...
824
			}
830
			}
825
		    }
831
		    }
826
		}
832
		}
827
	    }
833
	    }
828
	}
834
	}
-
 
835
	if (c->part < PART_BODY) {
829
	/* we end here if we processed a buffer of exactly one line */
836
	    /* we end here if we processed a buffer of exactly one line */
830
	c->line_pos = 0;
837
	    c->line_pos = 0;
831
	return;
-
 
832
    } else if (c->part == PART_BODY && c->body) { /* BODY  - this branch always returns */
-
 
833
	DBG(printf("BODY: body_pos=%d, content_length=%d\n", c->body_pos, c->content_length));
-
 
834
	n = recv(c->sock, c->body + c->body_pos, c->content_length - c->body_pos, 0);
-
 
835
	DBG(printf("      [recv n=%d - had %u of %u]\n", n, c->body_pos, c->content_length));
-
 
836
	if (n < 0) { /* error, scrap this worker */
-
 
837
	    remove_worker(c);
-
 
838
	    return;
838
	    return;
839
	}
839
	}
-
 
840
    }
-
 
841
    if (c->part == PART_BODY && c->body) { /* BODY  - this branch always returns */
-
 
842
	if (c->body_pos < c->content_length) { /* need to receive more ? */
-
 
843
	    DBG(printf("BODY: body_pos=%d, content_length=%d\n", c->body_pos, c->content_length));
-
 
844
	    n = recv(c->sock, c->body + c->body_pos, c->content_length - c->body_pos, 0);
-
 
845
	    DBG(printf("      [recv n=%d - had %u of %u]\n", n, c->body_pos, c->content_length));
-
 
846
	    c->line_pos = 0;
-
 
847
	    if (n < 0) { /* error, scrap this worker */
-
 
848
		remove_worker(c);
-
 
849
		return;
-
 
850
	    }
840
	if (n == 0) { /* connection closed -> try to process and then remove */
851
	    if (n == 0) { /* connection closed -> try to process and then remove */
841
	    process_request(c);
852
		process_request(c);
842
	    remove_worker(c);
853
	    remove_worker(c);
843
	    return;
854
		return;
-
 
855
	    }
-
 
856
	    c->body_pos += n;
844
	}
857
	}
845
	c->body_pos += n;
-
 
846
	if (c->body_pos == c->content_length) { /* yay! we got the whole body */
858
	if (c->body_pos == c->content_length) { /* yay! we got the whole body */
847
	    process_request(c);
859
	    process_request(c);
848
	    if (c->attr & CONNECTION_CLOSE) {
860
	    if (c->attr & CONNECTION_CLOSE || c->line_pos) { /* we have to close the connection if there was a double-hit */
849
		remove_worker(c);
861
		remove_worker(c);
850
		return;
862
		return;
851
	    }
863
	    }
852
	    /* keep-alive - reset the worker so it can process a new request */
864
	    /* keep-alive - reset the worker so it can process a new request */
853
	    if (c->url) { free(c->url); c->url = NULL; }
865
	    if (c->url) { free(c->url); c->url = NULL; }