static int core_input_filter(ap_filter_t *f, ap_bucket_brigade *b)
{
- char *buff;
- apr_ssize_t length = HUGE_STRING_LEN;
apr_socket_t *csock = NULL;
- apr_status_t rv;
ap_bucket *e;
- /* As soon as we have pool buckets, this should become a palloc. */
- buff = apr_palloc(f->c->pool, HUGE_STRING_LEN);
ap_bpop_socket(&csock, f->c->client);
-
- rv = apr_recv(csock, buff, &length);
- if (rv == APR_SUCCESS) {
- if (length > 0) {
- /* This should probably be a pool bucket, but using a transient is
- * actually okay here too. We know the pool we are using will always
- * be available as long as the connection is open.
- */
- e = ap_bucket_create_transient(buff, length);
- AP_BRIGADE_INSERT_TAIL(b, e);
- }
- else {
- /* XXX need to trigger EOS/EOF processing;
- * for now, return empty brigade because that is what
- * getline() looks for */
- }
- }
- else {
- return rv;
- }
+ e = ap_bucket_create_socket(csock);
+ AP_BRIGADE_INSERT_TAIL(b, e);
return APR_SUCCESS;
}
+
/* Default filter. This filter should almost always be used. Its only job
* is to send the headers if they haven't already been sent, and then send
* the actual data.
char *buff;
apr_ssize_t length;
char *pos;
- int state = 0;
http_ctx_t *ctx = f->ctx;
ap_bucket_brigade *bb;
apr_status_t rv;
return rv;
}
- pos = buff + 1;
+ pos = buff;
while (pos < buff + length) {
-
- /* We are at the start of one line, but it actually has data. */
- if ((*pos != ASCII_LF) && (*pos != ASCII_CR)) {
- state = 0;
- }
- else {
- if (*pos == ASCII_LF) {
- state++;
+ if (*pos == ASCII_LF) {
+ if (*(pos - 1) == ASCII_CR) {
+ *(pos - 1) = ASCII_LF;
+ *pos = '\0';
}
- }
-
- if ((*pos == ASCII_LF) && (*(pos - 1) == ASCII_CR)) {
- *(pos - 1) = ASCII_LF;
- *pos = '\0';
- }
- pos++;
- if (state == 2) {
- e->split(e, pos - buff);
+ e->split(e, pos - buff + (*pos == '\0'));
bb = ap_brigade_split(b, AP_BUCKET_NEXT(e));
ctx->b = bb;
return APR_SUCCESS;
}
+ pos++;
}
}
return APR_SUCCESS;
if (AP_BRIGADE_EMPTY(b)) {
return -1;
}
- e = AP_BRIGADE_FIRST(b);
while (1) {
+ e = AP_BRIGADE_FIRST(b);
while (e->length == 0) {
AP_BUCKET_REMOVE(e);
ap_bucket_destroy(e);
/* check for line end using ascii encoding, even on an ebcdic box
* since this is raw protocol data fresh from the network
*/
+/*XXX This needs to be scrubbed, but Greg Ames is going to do a lot to this
+ * code in a little while. When he is done, it shouldn't need scrubbing
+ * any more.
+ *
+ * GREG, this is where the breakage is!!!!
+ */
if ((toss = ap_strchr_c(temp, ASCII_LF)) != NULL) {
- length = toss - temp + 1;
- e->split(e, length + (temp[length] == '\0'));
+ length = (toss - temp) + (pos - s) + 1;
+ e->split(e, length + (temp[length] == '\0'));
apr_cpystrn(pos, temp, length + 1);
-
AP_BUCKET_REMOVE(e);
ap_bucket_destroy(e);
}
+ else {
+ apr_cpystrn(pos, temp, length + 1);
+ pos += length;
+ AP_BUCKET_REMOVE(e);
+ ap_bucket_destroy(e);
+ continue;
+ }
c->input_data = b;
e = AP_BRIGADE_FIRST(b);
/**** XXX