httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jac...@apache.org
Subject cvs commit: httpd-test/flood config.h.in flood_round_robin.c
Date Fri, 06 Sep 2002 10:16:10 GMT
jacekp      2002/09/06 03:16:09

  Modified:    flood    config.h.in flood_round_robin.c
  Log:
  Added basic auth. Following URL:
  <url user="foo" password="bar">http://localhost/auth</url>
  ...causes appropriate Authorization header to be sent.
  
  You have to know when you need auth enabled. Auth challenge (401 header)
  is treated (along with all 4xx type responses) as error.
  
  Revision  Changes    Path
  1.24      +2 -0      httpd-test/flood/config.h.in
  
  Index: config.h.in
  ===================================================================
  RCS file: /home/cvs/httpd-test/flood/config.h.in,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- config.h.in	23 Jul 2002 18:44:07 -0000	1.23
  +++ config.h.in	6 Sep 2002 10:16:09 -0000	1.24
  @@ -28,6 +28,8 @@
   #define XML_URLLIST_PREDELAYPRECISION "predelayprecision"
   #define XML_URLLIST_POSTDELAY "postdelay"
   #define XML_URLLIST_POSTDELAYPRECISION "postdelayprecision"
  +#define XML_URLLIST_USER "user"
  +#define XML_URLLIST_PASSWORD "password"
   #define XML_URLLIST_NAME "name"
   #define XML_PROFILE "profile"
   #define XML_PROFILE_COUNT "count"
  
  
  
  1.29      +36 -0     httpd-test/flood/flood_round_robin.c
  
  Index: flood_round_robin.c
  ===================================================================
  RCS file: /home/cvs/httpd-test/flood/flood_round_robin.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- flood_round_robin.c	6 Sep 2002 09:42:56 -0000	1.28
  +++ flood_round_robin.c	6 Sep 2002 10:16:09 -0000	1.29
  @@ -60,6 +60,7 @@
   #include <apr_uri.h>
   #include <apr_lib.h>
   #include <apr_hash.h>
  +#include <apr_base64.h>
   
   #if APR_HAVE_STRINGS_H
   #include <strings.h>    /* strncasecmp */
  @@ -115,6 +116,8 @@
       char *responsetemplate;
       char *responsename;
       int responselen;
  +    char *user;
  +    char *password;
   } url_t;
   
   typedef struct cookie_t {
  @@ -244,7 +247,9 @@
   apr_status_t round_robin_create_req(profile_t *profile, request_t *r)
   {
       round_robin_profile_t *p;
  +    int crdlen;
       char *cookies;
  +    char *enc_credtls, *credtls, *authz_hdr = NULL;
       cookie_t *cook;
      
       p = (round_robin_profile_t*)profile; 
  @@ -271,6 +276,19 @@
       else
           cookies = "";
   
  +    if (p->url[p->current_url].user) {
  +        if (!p->url[p->current_url].password) {
  +            apr_file_printf(local_stderr, "missing password for user '%s'\n", p->url[p->current_url].user);
  +            return APR_EGENERAL;
  +	} else {
  +	    credtls = apr_pstrcat(r->pool, p->url[p->current_url].user, ":", p->url[p->current_url].password,
NULL);
  +	    crdlen = strlen(credtls);
  +	    enc_credtls = (char *) apr_palloc(r->pool, apr_base64_encode_len(crdlen) + 1);
  +	    apr_base64_encode(enc_credtls, credtls, crdlen);
  +	    authz_hdr = apr_pstrcat(r->pool, "Authorization: Basic ", enc_credtls, CRLF, NULL);
  +	}
  +    }
  +
       switch (r->method)
       {
       case GET:
  @@ -279,12 +297,14 @@
                                  "User-Agent: Flood/" FLOOD_VERSION CRLF
                                  "Connection: %s" CRLF
                                  "Host: %s" CRLF 
  +                               "%s"
                                  "%s" CRLF,
                                  r->parsed_uri->path, 
                                  r->parsed_uri->query ? "?" : "",
                                  r->parsed_uri->query ? r->parsed_uri->query
: "",
                                  r->keepalive ? "Keep-Alive" : "Close",
                                  r->parsed_uri->hostinfo,
  +                               authz_hdr ? authz_hdr : "",
                                  cookies);
           r->rbuftype = POOL;
           r->rbufsize = strlen(r->rbuf);
  @@ -295,12 +315,14 @@
                                  "User-Agent: Flood/" FLOOD_VERSION CRLF
                                  "Connection: %s" CRLF
                                  "Host: %s" CRLF 
  +                               "%s"
                                  "%s" CRLF,
                                  r->parsed_uri->path, 
                                  r->parsed_uri->query ? "?" : "",
                                  r->parsed_uri->query ? r->parsed_uri->query
: "",
                                  r->keepalive ? "Keep-Alive" : "Close",
                                  r->parsed_uri->hostinfo,
  +                               authz_hdr ? authz_hdr : "",
                                  cookies);
           r->rbuftype = POOL;
           r->rbufsize = strlen(r->rbuf);
  @@ -315,6 +337,7 @@
                                      "Host: %s" CRLF
                                      "Content-Length: %d" CRLF 
                                      "Content-type: application/x-www-form-urlencoded" CRLF
  +                                   "%s"
                                      "%s" CRLF
                                      "%s",
                                      r->parsed_uri->path, 
  @@ -323,6 +346,7 @@
                                      r->keepalive ? "Keep-Alive" : "Close",
                                      r->parsed_uri->hostinfo,
                                      r->payloadsize,
  +                                   authz_hdr ? authz_hdr : "",
                                      cookies,
                                      (char*)r->payload);
           } else { /* There is no payload, but it's still a POST */
  @@ -332,12 +356,14 @@
                                      "Connection: %s" CRLF
                                      "Host: %s" CRLF
   
  +                                   "%s"
                                      "%s" CRLF "",
                                      r->parsed_uri->path, 
                                      r->parsed_uri->query ? "?" : "",
                                      r->parsed_uri->query ? r->parsed_uri->query
: "",
                                      r->keepalive ? "Keep-Alive" : "Close",
                                      r->parsed_uri->hostinfo,
  +                                   authz_hdr ? authz_hdr : "",
                                      cookies);
           }
           r->rbuftype = POOL;
  @@ -468,6 +494,16 @@
                                    FLOOD_STRLEN_MAX) == 0) {
                   url->responsename = (char*)attr->value;
                   url->responselen = strlen((char*)attr->value);
  +            }
  +            else if (strncasecmp(attr->name, 
  +                                 XML_URLLIST_USER,
  +                                 FLOOD_STRLEN_MAX) == 0) {
  +                url->user = (char*)attr->value;
  +            }
  +            else if (strncasecmp(attr->name, 
  +                                 XML_URLLIST_PASSWORD,
  +                                 FLOOD_STRLEN_MAX) == 0) {
  +                url->password = (char*)attr->value;
               }
               attr = attr->next;
           }
  
  
  

Mime
View raw message