Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75B91C6EB for ; Fri, 1 Nov 2013 12:41:05 +0000 (UTC) Received: (qmail 83606 invoked by uid 500); 1 Nov 2013 12:41:02 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 83351 invoked by uid 500); 1 Nov 2013 12:40:56 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 83342 invoked by uid 99); 1 Nov 2013 12:40:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Nov 2013 12:40:53 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Nov 2013 12:40:51 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C4DCD23888E4; Fri, 1 Nov 2013 12:40:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1537915 - /httpd/httpd/trunk/docs/manual/developer/modguide.xml Date: Fri, 01 Nov 2013 12:40:29 -0000 To: cvs@httpd.apache.org From: humbedooh@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131101124029.C4DCD23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: humbedooh Date: Fri Nov 1 12:40:29 2013 New Revision: 1537915 URL: http://svn.apache.org/r1537915 Log: Fixes to the modguide, courtesy of Petter Berntsen (sluggr) Modified: httpd/httpd/trunk/docs/manual/developer/modguide.xml Modified: httpd/httpd/trunk/docs/manual/developer/modguide.xml URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/developer/modguide.xml?rev=1537915&r1=1537914&r2=1537915&view=diff ============================================================================== --- httpd/httpd/trunk/docs/manual/developer/modguide.xml (original) +++ httpd/httpd/trunk/docs/manual/developer/modguide.xml Fri Nov 1 12:40:29 2013 @@ -1610,31 +1610,38 @@ keyValuePair* readPost(request_rec* r) { if (res != OK || !pairs) return NULL; /* Return NULL if we failed or if there are is no POST data */ kvp = apr_pcalloc(r->pool, sizeof(keyValuePair) * (pairs->nelts + 1)); while (pairs && !apr_is_empty_array(pairs)) { - i++; ap_form_pair_t *pair = (ap_form_pair_t *) apr_array_pop(pairs); apr_brigade_length(pair->value, 1, &len); size = (apr_size_t) len; buffer = apr_palloc(r->pool, size + 1); apr_brigade_flatten(pair->value, buffer, &size); buffer[len] = 0; - kvp[i]->key = apr_pstrdup(r->pool, pair->name); - kvp[i]->value = buffer; + kvp[i].key = apr_pstrdup(r->pool, pair->name); + kvp[i].value = buffer; + i++; } - return kvp; + return kvp; } -static int example_handler(request_rec *r) +static int example_handler(request_rec *r) { /*~~~~~~~~~~~~~~~~~~~~~~*/ - keyValuePair* formData; /*~~~~~~~~~~~~~~~~~~~~~~*/ formData = readPost(r); if (formData) { int i; - for (i = 0; formData[i]; i++) { - ap_rprintf(r, "%s = %s\n", formData[i]->key, formData[i]->value); + for (i = 0; &formData[i]; i++) { + if (formData[i].key && formData[i].value) { + ap_rprintf(r, "%s = %s\n", formData[i].key, formData[i].value); + } else if (formData[i].key) { + ap_rprintf(r, "%s\n", formData[i].key); + } else if (formData[i].value) { + ap_rprintf(r, "= %s\n", formData[i].value); + } else { + break; + } } } return OK; @@ -1644,13 +1651,13 @@ static int example_handler(request_rec * - +
Printing out every HTTP header received - + -static int example_handler(request_rec *r) +static int example_handler(request_rec *r) { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ const apr_array_header_t *fields; @@ -1661,7 +1668,7 @@ static int example_handler(request_rec * fields = apr_table_elts(r->headers_in); e = (apr_table_entry_t *) fields->elts; for(i = 0; i < fields->nelts; i++) { - ap_rprintf(r, "<b>%s</b>: %s<br/>", e[i].key, e[i].val); + ap_rprintf(r, "%s: %s\n", e[i].key, e[i].val); } return OK; } @@ -1670,9 +1677,9 @@ static int example_handler(request_rec *
- +
Reading the request body into memory - + @@ -1718,8 +1725,8 @@ static int example_handler(request_rec* const char *buffer; /*~~~~~~~~~~~~~~~~*/ - if(util_read(r, &data, &size) == OK) { - ap_rprintf(r, "We read a request body that was %u bytes long", size); + if(util_read(r, &buffer, &size) == OK) { + ap_rprintf(r, "We read a request body that was %" APR_OFF_T_FMT " bytes long", size); } return OK; }