You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2003/01/29 17:02:18 UTC
cvs commit: httpd-2.0/modules/arch/win32 mod_isapi.c
wrowe 2003/01/29 08:02:18
Modified: modules/arch/win32 mod_isapi.c
Log:
Allow headers (if not already passed by other means) to be sent via
WriteFile() since the foxisapi and other thunks seem to indicate that
headers within the WriteFile() operation are expected to succeed.
Also assure that all ->completion callbacks get the original size of
the document.
Revision Changes Path
1.89 +57 -34 httpd-2.0/modules/arch/win32/mod_isapi.c
Index: mod_isapi.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/arch/win32/mod_isapi.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- mod_isapi.c 11 Nov 2002 05:58:39 -0000 1.88
+++ mod_isapi.c 29 Jan 2003 16:02:17 -0000 1.89
@@ -626,38 +626,6 @@
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 @@
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 @@
}
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;
@@ -1575,6 +1596,8 @@
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;