httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject cvs commit: httpd-proxy/module-2.0 mod_proxy.c mod_proxy.h proxy_connect.c proxy_ftp.c proxy_http.c proxy_util.c
Date Sat, 14 Apr 2001 07:03:01 GMT
minfrin     01/04/14 00:03:01

  Modified:    module-2.0 mod_proxy.c mod_proxy.h proxy_connect.c
                        proxy_ftp.c proxy_http.c proxy_util.c
  Log:
  Make hooks work for the *_canon() functions. Work continues.
  
  Revision  Changes    Path
  1.42      +6 -15     httpd-proxy/module-2.0/mod_proxy.c
  
  Index: mod_proxy.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/mod_proxy.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- mod_proxy.c	2001/04/13 23:56:04	1.41
  +++ mod_proxy.c	2001/04/14 07:02:59	1.42
  @@ -66,7 +66,7 @@
   )
   
   AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_scheme_handler, (request_rec *r, char *url, const
char *proxyhost, apr_port_t proxyport),(r,url,proxyhost,proxyport),DECLINED)
  -AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_canon_handler, (request_rec *r, char *url, const
char *scheme, apr_port_t def_port),(r,url,scheme,def_port),DECLINED)
  +AP_IMPLEMENT_HOOK_RUN_FIRST(int, proxy_canon_handler, (request_rec *r, char *url),(r,url),DECLINED)
   
   
   /*
  @@ -205,17 +205,17 @@
   static int proxy_fixup(request_rec *r)
   {
       char *url, *p;
  +    int access_status;
   
       if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
   	return DECLINED;
   
       url = &r->filename[6];
   
  -/* canonicalise each specific scheme */
  -    if (strncasecmp(url, "http:", 5) == 0)
  -	return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
  -    else if (strncasecmp(url, "ftp:", 4) == 0)
  -	return ap_proxy_ftp_canon(r, url + 4, NULL, 0);
  +    /* canonicalise each specific scheme */
  +    if ((access_status = ap_run_proxy_canon_handler(r, url))) {
  +	return access_status;
  +    }
   
       p = strchr(url, ':');
       if (p == NULL || p == url)
  @@ -279,7 +279,6 @@
       int i, rc;
       int direct_connect = 0;
       const char *str;
  -    const char *pragma, *auth, *imstr;
       long maxfwd;
   
       /* is this for us? */
  @@ -331,14 +330,6 @@
       p = strchr(url, ':');
       if (p == NULL)
   	return HTTP_BAD_REQUEST;
  -
  -    pragma = apr_table_get(r->headers_in, "Pragma");
  -    auth = apr_table_get(r->headers_in, "Authorization");
  -    imstr = apr_table_get(r->headers_in, "If-Modified-Since");
  -
  -    ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,
  -                 "Request for %s, pragma=%s, auth=%s, imstr=%s", url,
  -                 pragma, auth, imstr);
   
       /* If the host doesn't have a domain name, add one and redirect. */
       if (conf->domain != NULL) {
  
  
  
  1.49      +5 -5      httpd-proxy/module-2.0/mod_proxy.h
  
  Index: mod_proxy.h
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/mod_proxy.h,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- mod_proxy.h	2001/04/13 23:56:04	1.48
  +++ mod_proxy.h	2001/04/14 07:02:59	1.49
  @@ -206,12 +206,13 @@
   
   /* proxy_connect.c */
   
  +int ap_proxy_connect_canon(request_rec *r, char *url);
   int ap_proxy_connect_handler(request_rec *r, char *url,
   			  const char *proxyhost, apr_port_t proxyport);
   
   /* proxy_ftp.c */
   
  -int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port);
  +int ap_proxy_ftp_canon(request_rec *r, char *url);
   int ap_proxy_ftp_handler(request_rec *r, char *url, const char *proxyhost, apr_port_t proxyport);
   apr_status_t ap_proxy_send_dir_filter(ap_filter_t *f,
   				      apr_bucket_brigade *bb);
  @@ -219,8 +220,7 @@
   
   /* proxy_http.c */
   
  -int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme,
  -		     apr_port_t def_port);
  +int ap_proxy_http_canon(request_rec *r, char *url);
   int ap_proxy_http_handler(request_rec *r, char *url,
   		       const char *proxyhost, apr_port_t proxyport);
   
  @@ -232,7 +232,7 @@
   char *ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
   			int isenc);
   char *ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
  -			 char **passwordp, char **hostp, int *port);
  +			 char **passwordp, char **hostp, apr_port_t *port);
   const char *ap_proxy_date_canon(apr_pool_t *p, const char *x);
   apr_table_t *ap_proxy_read_headers(request_rec *r, request_rec *rp, char *buffer, int size,
conn_rec *c);
   int ap_proxy_liststr(const char *list, const char *val);
  @@ -255,7 +255,7 @@
   
   
   AP_DECLARE_HOOK(int, proxy_scheme_handler, (request_rec *r, char *url, const char *proxyhost,
apr_port_t proxyport))
  -AP_DECLARE_HOOK(int, proxy_canon_handler, (request_rec *r, char *url, const char *scheme,
apr_port_t def_port))
  +AP_DECLARE_HOOK(int, proxy_canon_handler, (request_rec *r, char *url))
   
   
   #endif /*MOD_PROXY_H*/
  
  
  
  1.41      +17 -0     httpd-proxy/module-2.0/proxy_connect.c
  
  Index: proxy_connect.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_connect.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- proxy_connect.c	2001/04/13 23:56:04	1.40
  +++ proxy_connect.c	2001/04/14 07:02:59	1.41
  @@ -100,6 +100,18 @@
       return 0;
   }
   
  +/* canonicalise CONNECT URLs. */
  +int ap_proxy_connect_canon(request_rec *r, char *url)
  +{
  +
  +    if (r->method_number != M_CONNECT) {
  +	return DECLINED;
  +    }
  +
  +    return OK;
  +}
  +
  +/* CONNECT handler */
   int ap_proxy_connect_handler(request_rec *r, char *url,
   			  const char *proxyname, apr_port_t proxyport)
   {
  @@ -122,6 +134,10 @@
       proxy_server_conf *conf =
       (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
   
  +    /* is this for us? */
  +    if (r->method_number != M_CONNECT) {
  +	return DECLINED;
  +    }
   
       /*
        * Step One: Determine Who To Connect To
  @@ -388,6 +404,7 @@
   static void ap_proxy_connect_register_hook(apr_pool_t *p)
   {
       ap_hook_proxy_scheme_handler(ap_proxy_connect_handler, NULL, NULL, APR_HOOK_MIDDLE);
  +    ap_hook_proxy_canon_handler(ap_proxy_connect_canon, NULL, NULL, APR_HOOK_MIDDLE);
   }
   
   module AP_MODULE_DECLARE_DATA proxy_connect_module = {
  
  
  
  1.47      +19 -10    httpd-proxy/module-2.0/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_ftp.c,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- proxy_ftp.c	2001/04/13 23:56:04	1.46
  +++ proxy_ftp.c	2001/04/14 07:02:59	1.47
  @@ -113,14 +113,23 @@
   /*
    * Canonicalise ftp URLs.
    */
  -int ap_proxy_ftp_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port)
  +int ap_proxy_ftp_canon(request_rec *r, char *url)
   {
       char *user, *password, *host, *path, *parms, *strp, sport[7];
       apr_pool_t *p = r->pool;
       const char *err;
  -    int port;
  +    apr_port_t port, def_port;
   
  -    port = DEFAULT_FTP_PORT;
  +    /* */
  +    if (strncasecmp(url, "ftp:", 4) == 0) {
  +	url += 4;
  +    }
  +    else {
  +	return DECLINED;
  +    }
  +    def_port = ap_default_port_for_scheme("ftp");
  +
  +    port = def_port;
       err = ap_proxy_canon_netloc(p, &url, &user, &password, &host, &port);
       if (err)
   	return HTTP_BAD_REQUEST;
  @@ -129,12 +138,12 @@
       if (password != NULL && !ftp_check_string(password))
   	return HTTP_BAD_REQUEST;
   
  -/* now parse path/parameters args, according to rfc1738 */
  -/* N.B. if this isn't a true proxy request, then the URL path
  - * (but not query args) has already been decoded.
  - * This gives rise to the problem of a ; being decoded into the
  - * path.
  - */
  +    /* now parse path/parameters args, according to rfc1738 */
  +    /* N.B. if this isn't a true proxy request, then the URL path
  +     * (but not query args) has already been decoded.
  +     * This gives rise to the problem of a ; being decoded into the
  +     * path.
  +     */
       strp = strchr(url, ';');
       if (strp != NULL) {
   	*(strp++) = '\0';
  @@ -170,7 +179,7 @@
   
   /* now, rebuild URL */
   
  -    if (port != DEFAULT_FTP_PORT)
  +    if (port != def_port)
   	apr_snprintf(sport, sizeof(sport), ":%d", port);
       else
   	sport[0] = '\0';
  
  
  
  1.60      +26 -11    httpd-proxy/module-2.0/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_http.c,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- proxy_http.c	2001/04/13 23:56:04	1.59
  +++ proxy_http.c	2001/04/14 07:03:00	1.60
  @@ -68,25 +68,40 @@
    *  url    is the URL starting with the first '/'
    *  def_port is the default port for this scheme.
    */
  -int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, apr_port_t def_port)
  +int ap_proxy_http_canon(request_rec *r, char *url)
   {
       char *host, *path, *search, sport[7];
       const char *err;
  -    int port;
  +    const char *scheme;
  +    apr_port_t port, def_port;
   
  -/* do syntatic check.
  - * We break the URL into host, port, path, search
  - */
  +    /* ap_default_port_for_scheme() */
  +    if (strncasecmp(url, "http:", 5) == 0) {
  +	url += 5;
  +	scheme = "http";
  +    }
  +    else if (strncasecmp(url, "https:", 6) == 0) {
  +	url += 6;
  +	scheme = "https:";
  +    }
  +    else {
  +	return DECLINED;
  +    }
  +    def_port = ap_default_port_for_scheme(scheme);
  +
  +    /* do syntatic check.
  +     * We break the URL into host, port, path, search
  +     */
       port = def_port;
       err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
       if (err)
   	return HTTP_BAD_REQUEST;
   
  -/* now parse path/search args, according to rfc1738 */
  -/* N.B. if this isn't a true proxy request, then the URL _path_
  - * has already been decoded.  True proxy requests have r->uri
  - * == r->unparsed_uri, and no others have that property.
  - */
  +    /* now parse path/search args, according to rfc1738 */
  +    /* N.B. if this isn't a true proxy request, then the URL _path_
  +     * has already been decoded.  True proxy requests have r->uri
  +     * == r->unparsed_uri, and no others have that property.
  +     */
       if (r->uri == r->unparsed_uri) {
   	search = strchr(url, '?');
   	if (search != NULL)
  @@ -95,7 +110,7 @@
       else
   	search = r->args;
   
  -/* process path */
  +    /* process path */
       path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, r->proxyreq);
       if (path == NULL)
   	return HTTP_BAD_REQUEST;
  
  
  
  1.54      +3 -3      httpd-proxy/module-2.0/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/httpd-proxy/module-2.0/proxy_util.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- proxy_util.c	2001/04/12 01:57:48	1.53
  +++ proxy_util.c	2001/04/14 07:03:00	1.54
  @@ -209,9 +209,9 @@
    */
   char *
        ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
  -			char **passwordp, char **hostp, int *port)
  +			char **passwordp, char **hostp, apr_port_t *port)
   {
  -    int i;
  +    apr_port_t i;
       char *strp, *host, *url = *urlp;
       char *user = NULL, *password = NULL;
   
  @@ -635,7 +635,7 @@
        proxy_get_host_of_request(request_rec *r)
   {
       char *url, *user = NULL, *password = NULL, *err, *host;
  -    int port = -1;
  +    apr_port_t port = -1;
   
       if (r->hostname != NULL)
   	return r->hostname;
  
  
  

Mime
View raw message