Fixes in TclWebapache.c
- wrong assumption about 'ap_set_content_type' called in
TclWeb_SetHeaderType: this function allows opaque handling of the
content_type field in 'request_rec', but does not duplicate the string passed
in by the caller whereas the pointer can be invalidated by Tcl. String is now
duplicated through call to apr_pstrdup.
- calls to 'ap_send_http_header' centralized in function TclWeb_SendHeaders
(also in src/apache-1/TclWebapache.c)
- added includes to silence some compilation warning.
-- Massimo
Index: src/apache-2/TclWebapache.c
===================================================================
--- src/apache-2/TclWebapache.c (revision 939494)
+++ src/apache-2/TclWebapache.c (working copy)
@@ -30,6 +30,8 @@
#endif
#include <tcl.h>
+#include <sys/types.h>
+#include <pwd.h>
#include <httpd.h>
#include <http_request.h>
@@ -69,7 +71,9 @@
TclWeb_SendHeaders(TclWebRequest *req)
{
//TODO: fix ap_send_http_header
+
ap_send_http_header(req->req);
+
return TCL_OK;
}
@@ -85,11 +89,13 @@
int
TclWeb_SetHeaderType(char *header, TclWebRequest *req)
{
+
if(req->headers_set)
return TCL_ERROR;
// req->req->content_type = (char *) apr_pstrdup(req->req->pool, header);
- ap_set_content_type(req->req,header);
+
+ ap_set_content_type(req->req,apr_pstrdup(req->req->pool, header));
req->headers_set = 1;
return TCL_OK;
}
@@ -102,13 +108,18 @@
return TCL_ERROR;
if (req->headers_set == 0)
+ {
TclWeb_SetHeaderType(DEFAULT_HEADER_TYPE, req);
-
+ }
+
/*
* seems that ap_send_http_header is redefined to ; in Apache2.2
* ap_send_http_header(req->req);
*/
- ap_send_http_header(req->req);
+
+ TclWeb_SendHeaders(req);
+ /* ap_send_http_header(req->req); */
+
req->headers_printed = 1;
return TCL_OK;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]