You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by ra...@apache.org on 2003/10/16 17:44:57 UTC

cvs commit: httpd-apreq-2/env/t big_request.t

randyk      2003/10/16 08:44:57

  Added:       env/c-modules/apreq_big_request_test
                        mod_apreq_big_request_test.c .cvsignore
               env/t    big_request.t
  Log:
  Reviewed by:	joes
  
  add mod_apreq_big_request_test to test large GET and POST requests.
  
  Revision  Changes    Path
  1.1                  httpd-apreq-2/env/c-modules/apreq_big_request_test/mod_apreq_big_request_test.c
  
  Index: mod_apreq_big_request_test.c
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #if CONFIG_FOR_HTTPD_TEST
  
  <Location /apreq_big_request_test>
     SetHandler apreq_big_request_test
  </Location>
  
  #endif
  
  #define APACHE_HTTPD_TEST_HANDLER apreq_big_request_test_handler
  
  #include "apache_httpd_test.h"
  #include "apreq_params.h"
  #include "apreq_env.h"
  #include "httpd.h"
  
  static int dump_table(void *count, const char *key, const char *value)
  {
      int *c = (int *) count;
      *c = *c + strlen(key) + strlen(value);
      return 1;
  }
  
  static int apreq_big_request_test_handler(request_rec *r)
  {
      apreq_request_t *req;
      apr_table_t *params;
      int count = 0;
  
      if (strcmp(r->handler, "apreq_big_request_test") != 0)
          return DECLINED;
  
      apreq_log(APREQ_DEBUG 0, r, "initializing request");
      req = apreq_request(r, NULL);
      params = apreq_params(r->pool, req);
      apr_table_do(dump_table, &count, params, NULL);
      ap_set_content_type(r, "text/plain");
      ap_rprintf(r, "%d", count);
      return OK;
  }
  
  APACHE_HTTPD_TEST_MODULE(apreq_big_request_test);
  
  
  
  1.1                  httpd-apreq-2/env/c-modules/apreq_big_request_test/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  .libs
  Makefile
  mod_apreq_big_request_test.la
  mod_apreq_big_request_test.slo
  
  
  
  1.1                  httpd-apreq-2/env/t/big_request.t
  
  Index: big_request.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestUtil;
  use Apache::TestConfig;
  use Apache::TestRequest qw(GET_BODY POST_BODY);
  
  my @key_len = (5, 100, 305);
  my @key_num = (5, 15, 26);
  my @keys    = ('a'..'z');
  
  my @big_key_len = (100, 500, 5000, 10000);
  my @big_key_num = (5, 15, 25);
  my @big_keys    = ('a'..'z');
  
  plan tests => @key_len * @key_num + @big_key_len * @big_key_num;
  
  my $location = "/apreq_big_request_test";
  
  # GET
  for my $key_len (@key_len) {
      for my $key_num (@key_num) {
          my @query = ();
          my $len = 0;
  
          for my $key (@keys[0..($key_num-1)]) {
              my $pair = "$key=" . 'd' x $key_len;
              $len += length($pair) - 1;
              push @query, $pair;
          }
          my $query = join ";", @query;
  
          t_debug "# of keys : $key_num, key_len $key_len";
          my $body = GET_BODY "$location?$query";
          ok t_cmp($len,
                   $body,
                   "GET long query");
      }
  
  }
  
  # POST
  for my $big_key_len (@big_key_len) {
      for my $big_key_num (@big_key_num) {
          my @query = ();
          my $len = 0;
  
          for my $big_key (@big_keys[0..($big_key_num-1)]) {
              my $pair = "$big_key=" . 'd' x $big_key_len;
              $len += length($pair) - 1;
              push @query, $pair;
          }
          my $query = join ";", @query;
  
          t_debug "# of keys : $big_key_num, big_key_len $big_key_len";
          my $body = POST_BODY($location, content => $query);
          ok t_cmp($len,
                   $body,
                   "POST big data");
      }
  
  }