mod_rndchunk.c revision 0f081398cf0eef8cc7c66a535d450110a92dc8ae
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen/* ====================================================================
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * Copyright (c) 1998-1999 The Apache Group. All rights reserved.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * Redistribution and use in source and binary forms, with or without
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * modification, are permitted provided that the following conditions
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * 1. Redistributions of source code must retain the above copyright
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * notice, this list of conditions and the following disclaimer.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * 2. Redistributions in binary form must reproduce the above copyright
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * notice, this list of conditions and the following disclaimer in
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * the documentation and/or other materials provided with the
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * distribution.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * 3. All advertising materials mentioning features or use of this
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * software must display the following acknowledgment:
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * "This product includes software developed by the Apache Group
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * for use in the Apache HTTP server project (http://www.apache.org/)."
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * 4. The names "Apache Server" and "Apache Group" must not be used to
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * endorse or promote products derived from this software without
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * prior written permission. For written permission, please contact
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * apache@apache.org.
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * 5. Products derived from this software may not be called "Apache"
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * nor may "Apache" appear in their names without prior written
39d8db043b599a7382f94bfc904d5e108af438bdLennart Poettering * permission of the Apache Group.
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering * 6. Redistributions of any form whatsoever must retain the following
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * acknowledgment:
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * "This product includes software developed by the Apache Group
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * for use in the Apache HTTP server project (http://www.apache.org/)."
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * OF THE POSSIBILITY OF SUCH DAMAGE.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * ====================================================================
a5a807e63a50314e190e9166d8a453cd8dd258e3Zbigniew Jędrzejewski-Szmek * This software consists of voluntary contributions made by many
cc56fafeebf814ef035e549115cf1850e6473fa5WaLyong Cho * individuals on behalf of the Apache Group and was originally based
a5a807e63a50314e190e9166d8a453cd8dd258e3Zbigniew Jędrzejewski-Szmek * on public domain software written at the National Center for
a5a807e63a50314e190e9166d8a453cd8dd258e3Zbigniew Jędrzejewski-Szmek * Supercomputing Applications, University of Illinois, Urbana-Champaign.
a5a807e63a50314e190e9166d8a453cd8dd258e3Zbigniew Jędrzejewski-Szmek * For more information on the Apache Group and the Apache HTTP server
a5a807e63a50314e190e9166d8a453cd8dd258e3Zbigniew Jędrzejewski-Szmek * project, please see <http://www.apache.org/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * This module is intended to be used for testing chunked encoding. It
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * generates a whole whack of output using ap_bputc() and ap_bputs(). It
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * also exercises start_chunk() and end_chunk() in buff.c. To use it
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * you should use a tool like netcat and the src/test/check_chunked
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * tool. Add something like this to your access.conf file:
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering * <Location /rndchunk>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * SetHandler rndchunk
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * </Location>
682265d5e2157882861b0091c6b81fa92699b72aTom Gundersen * Then fake requests such as:
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * GET /rndchunk?0,1000000 HTTP/1.1
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * Host: localhost
b9e7a9d870ac41d4db954edd52a1f5dd7d153389Lennart Poettering * The first arg is the random seed, the second is the number of
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * "things" to do. You should try a few seeds.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * You should also edit main/buff.c and change DEFAULT_BUFSIZE (and
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering * CHUNK_HEADER_SIZE). Small values are particularly useful for
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen * finding bugs. Try a few different values.
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen unsigned int seed;
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen unsigned int count;
091a364c802e34a58f3260c9cb5db9b75c62215cTom Gundersen unsigned int len;
if (!args) {
ap_kill_timeout(r);
goto error;
++endptr;
for (i = 0; i < count; ++i) {
else if (len == 0) {
ap_kill_timeout(r);
{NULL}