Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 4518 invoked from network); 15 Nov 2009 02:44:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Nov 2009 02:44:25 -0000 Received: (qmail 27099 invoked by uid 500); 15 Nov 2009 02:44:24 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 26999 invoked by uid 500); 15 Nov 2009 02:44:24 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 26989 invoked by uid 99); 15 Nov 2009 02:44:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Nov 2009 02:44:24 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [68.230.240.7] (HELO eastrmmtao101.cox.net) (68.230.240.7) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Nov 2009 02:44:12 +0000 Received: from eastrmimpo03.cox.net ([68.1.16.126]) by eastrmmtao101.cox.net (InterMail vM.8.00.01.00 201-2244-105-20090324) with ESMTP id <20091115024352.GHWL6358.eastrmmtao101.cox.net@eastrmimpo03.cox.net> for ; Sat, 14 Nov 2009 21:43:52 -0500 Received: from eastrmwml32 ([172.18.18.217]) by eastrmimpo03.cox.net with bizsmtp id 5Ejr1d0064h0NJL02Ejr3D; Sat, 14 Nov 2009 21:43:51 -0500 X-VR-Score: -90.00 X-Authority-Analysis: v=1.0 c=1 a=5PLM-36HX18A:10 a=GPYG1n6kjboA:10 a=kviXuzpPAAAA:8 a=LN_GVo-4AAAA:8 a=ZO_AHefkAAAA:8 a=zgdD4KTVHDFk2mIukCQA:9 a=AJWZ1IZMrbYfLejOEm4A:7 a=nZMUKxsAu4R2aAtCy7lPRn3snBYA:4 a=62hRBlzVkFMA:10 a=4vB-4DCPJfMA:10 a=-brq4aOXzhnL96Sc:21 a=UBj7jzgpNE0G4Brk:21 X-CM-Score: 0.00 Received: from 70.177.187.4 by webmail.east.cox.net; Sat, 14 Nov 2009 21:43:51 -0500 Message-ID: <20091114214352.WER6K.971094.imail@eastrmwml32> Date: Sat, 14 Nov 2009 21:43:52 -0500 From: To: modules-dev@httpd.apache.org Subject: Re: ap_sub_req_lookup_uri(r->uri, r, NULL)->content_type always returns 'text/plain'? In-Reply-To: <20091114193738.HTA84.970121.imail@eastrmwml32> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) Sensitivity: Normal X-Virus-Checked: Checked by ClamAV on apache.org ---- ohaya@cox.net wrote: > Hi, > > I'm not sure if this is the appropriate list, or if I should post on the regular httpd list... > > I've been trying to work with an Apache module, mod_limitipconn: > > http://dominia.org/djao/limitipconn2.html > > This is with Apache 2.2.8/2.2.11. > > Our use case is slightly different that the original one for this module. The original code is designed to limit the number of connections from any given IP address, whereas in my case, we want to limit the total number of connections to the entire Apache server instance. > > To do that, I commented out one line (an 'if'), as shown below: > > /* Count up the number of connections we are handling right now from > * this IP address */ > /* This is modified to not do strcmp(address, ws_record->client check, in order > to count ALL connections to this server. */ > for (i = 0; i < server_limit; ++i) { > for (j = 0; j < thread_limit; ++j) { > ws_record = ap_get_scoreboard_worker(i, j); > switch (ws_record->status) { > case SERVER_BUSY_READ: > case SERVER_BUSY_WRITE: > case SERVER_BUSY_KEEPALIVE: > case SERVER_BUSY_LOG: > case SERVER_BUSY_DNS: > case SERVER_CLOSING: > case SERVER_GRACEFUL: > /* > if (strcmp(address, ws_record->client) == 0) > */ > ip_count++; > break; > default: > break; > } > } > } > > and, after I rebuilt the module, it seems to work ok. > > Now, I'm trying to get the module's directive "NoIPLimit" to work. > > According to the README, plus reading the code, the way that this is suppose to work is that if you specify a MIME type string (substring, actually), the module won't "count" requests that have any of the MIME types in the directive. > > I have the Apache LogLevel set to debug, and it looks like the "content_type" that the module is retrieving from ALL requests is "text/plain", and I have confirmed that the actual MIME types are not "text/plain" (I see things like "image/gif", "text/css", etc.), so the "NoIPLimit" directive doesn't work. > > From reading the code, I think that the "content_type" is set in this snippet: > > /* Only check the MIME-type if we have MIME-type stuff in our config. > The extra subreq can be quite expensive. */ > if(cfg->no_limit->nelts > 0 || cfg->excl_limit->nelts > 0) { > /* Look up the Content-type of this request. We need a subrequest > * here since this module might be called before the URI has been > * translated into a MIME type. */ > content_type = ap_sub_req_lookup_uri(r->uri, r, NULL)->content_type; > > /* If there's no Content-type, use the default. */ > if (!content_type) { > content_type = ap_default_type(r); > } > > ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, > "mod_limitipconn: uri: %s Content-Type: %s", > r->uri, content_type); > > /* Cycle through the exempt list; if our content_type is exempt, > * return OK */ > for (i = 0; i < cfg->no_limit->nelts; i++) { > if ((ap_strcasecmp_match(content_type, nolim[i]) == 0) > || (strncmp(nolim[i], content_type, strlen(nolim[i])) == 0)) > { > ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, > "mod_limitipconn: OK: %s exempt", content_type); > return DECLINED; > } > } > > and, in particular: > > content_type = ap_sub_req_lookup_uri(r->uri, r, NULL)->content_type; > > /* If there's no Content-type, use the default. */ > if (!content_type) { > content_type = ap_default_type(r); > } > > I'm not that familiar with Apache module development, but reading the docs, it *seems* like the above *should* work. > > I'm assuming you all on this list *are* familiar with module development, so I was wondering if you might be able to tell me what, if anything, is wrong with that code (i.e., why is "content_type" not being set with the actual content type? > > Thanks in advance!! > > Jim Hi, BTW, here's an example of the Apache debug output for mod_limitipconn that illustrates what I'm seeing: [Sun Nov 15 02:21:09 2009] [debug] mod_limitipconn.c(143): [client 192.168.xx.yy] mod_limitipconn: uri: /anewwsclient/css/body.css Content-Type: text/plain, referer: http://foo.host.com/anewwsclient As you can see, the URI is for a .css, but the Content-Type comes back as "text/plain, referer: http://foo.host.com/anewwsclient", then, since the mod_limitipconn code checks for the MIME types in the NoIPLimit directive, (e.g., image/* text/css/*), it fails to detect this as a MIME type that it should ignore. Shouldn't the Content-Type be something like "text/css, referer: http://foo.host.com/anewwsclient"? Jim