summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/arch/win32/mod_isapi.c91
1 files changed, 57 insertions, 34 deletions
diff --git a/modules/arch/win32/mod_isapi.c b/modules/arch/win32/mod_isapi.c
index 9349663db5..f8bfdb68d3 100644
--- a/modules/arch/win32/mod_isapi.c
+++ b/modules/arch/win32/mod_isapi.c
@@ -626,38 +626,6 @@ int APR_THREAD_FUNC GetServerVariable (isapi_cid *cid,
return 0;
}
-int APR_THREAD_FUNC WriteClient(isapi_cid *cid,
- void *buf_data,
- apr_uint32_t *buf_size,
- apr_uint32_t flags)
-{
- request_rec *r = cid->r;
- conn_rec *c = r->connection;
- apr_bucket_brigade *bb;
- apr_bucket *b;
- apr_status_t rv;
-
- bb = apr_brigade_create(r->pool, c->bucket_alloc);
- b = apr_bucket_transient_create(buf_data, *buf_size, c->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(bb, b);
- b = apr_bucket_flush_create(c->bucket_alloc);
- APR_BRIGADE_INSERT_TAIL(bb, b);
- rv = ap_pass_brigade(r->output_filters, bb);
- cid->response_sent = 1;
-
- if ((flags & HSE_IO_ASYNC) && cid->completion) {
- if (rv == OK) {
- cid->completion(cid->ecb, cid->completion_arg,
- *buf_size, ERROR_SUCCESS);
- }
- else {
- cid->completion(cid->ecb, cid->completion_arg,
- *buf_size, ERROR_WRITE_FAULT);
- }
- }
- return (rv == OK);
-}
-
int APR_THREAD_FUNC ReadClient(isapi_cid *cid,
void *buf_data,
apr_uint32_t *buf_size)
@@ -813,6 +781,58 @@ static apr_ssize_t send_response_header(isapi_cid *cid,
return ate;
}
+int APR_THREAD_FUNC WriteClient(isapi_cid *cid,
+ void *buf_data,
+ apr_uint32_t *size_arg,
+ apr_uint32_t flags)
+{
+ request_rec *r = cid->r;
+ conn_rec *c = r->connection;
+ apr_uint32_t buf_size = *size_arg;
+ apr_bucket_brigade *bb;
+ apr_bucket *b;
+ apr_status_t rv;
+
+ if (!cid->headers_set) {
+ /* It appears that the foxisapi module and other clients
+ * presume that WriteClient("headers\n\nbody") will work.
+ * Parse them out, or die trying.
+ */
+ apr_ssize_t ate;
+ ate = send_response_header(cid, (char*)buf_data,
+ NULL, buf_size, 0);
+ if (ate < 0) {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
+ }
+
+ (char*)buf_data += ate;
+ buf_size -= ate;
+ }
+
+ if (buf_size) {
+ bb = apr_brigade_create(r->pool, c->bucket_alloc);
+ b = apr_bucket_transient_create(buf_data, buf_size, c->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+ b = apr_bucket_flush_create(c->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+ rv = ap_pass_brigade(r->output_filters, bb);
+ cid->response_sent = 1;
+ }
+
+ if ((flags & HSE_IO_ASYNC) && cid->completion) {
+ if (rv == OK) {
+ cid->completion(cid->ecb, cid->completion_arg,
+ *size_arg, ERROR_SUCCESS);
+ }
+ else {
+ cid->completion(cid->ecb, cid->completion_arg,
+ *size_arg, ERROR_WRITE_FAULT);
+ }
+ }
+ return (rv == OK);
+}
+
int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
apr_uint32_t HSE_code,
void *buf_data,
@@ -1042,10 +1062,11 @@ int APR_THREAD_FUNC ServerSupportFunction(isapi_cid *cid,
}
if (tf->pHead && (apr_size_t)ate < tf->HeadLength) {
- sent = tf->HeadLength - ate;
b = apr_bucket_transient_create((char*)tf->pHead + ate,
- sent, c->bucket_alloc);
+ tf->HeadLength - ate,
+ c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
+ sent = tf->HeadLength;
}
sent += (apr_uint32_t)fsize;
@@ -1576,6 +1597,8 @@ apr_status_t isapi_handler (request_rec *r)
bb = apr_brigade_create(r->pool, c->bucket_alloc);
b = apr_bucket_eos_create(c->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(bb, b);
+ b = apr_bucket_flush_create(c->bucket_alloc);
+ APR_BRIGADE_INSERT_TAIL(bb, b);
rv = ap_pass_brigade(r->output_filters, bb);
cid->response_sent = 1;