You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Michael Douglass <mi...@texas.net> on 1998/01/23 23:20:48 UTC

[patch] correctly redirect URLs based on connection information.

Okay, the word interpretation is up for questioning; but here is a revised
patch that incorporates things that were discussed since that point.  Any
consideration for adding to 1.3?

(Oh, the patch is against 1.2.5; sorry. :)

*** /tmp/T05K5mO_       Fri Jan 23 13:15:59 1998
--- mod_dir.c   Wed Jan 21 22:51:52 1998
***************
*** 810,816 ****
                         "/", NULL);

        table_set (r->headers_out, "Location",
!                  construct_url(r->pool, ifile, r->server));
        return HTTP_MOVED_PERMANENTLY;
      }

--- 810,816 ----
                         "/", NULL);

        table_set (r->headers_out, "Location",
!                  construct_url(r->pool, ifile, r));
        return HTTP_MOVED_PERMANENTLY;
      }

*** /tmp/T05K5mO_       Fri Jan 23 13:15:59 1998
--- mod_imap.c  Wed Jan 21 22:52:25 1998
***************
*** 381,387 ****
      char *my_base;

      if (!strcasecmp(value, "map") || !strcasecmp(value, "menu")) {
!       return construct_url(r->pool, r->uri, r->server);
      }

      if (!strcasecmp(value, "nocontent") || !strcasecmp(value, "error")) {
--- 381,387 ----
      char *my_base;

      if (!strcasecmp(value, "map") || !strcasecmp(value, "menu")) {
!       return construct_url(r->pool, r->uri, r);
      }

      if (!strcasecmp(value, "nocontent") || !strcasecmp(value, "error")) {
***************
*** 417,423 ****
            return pstrdup(r->pool, value); /* no base: use what is given */
          }
        /* no base, no value: pick a simple default */
!       return construct_url(r->pool, "/", r->server);
      }

      /* must be a relative URL to be combined with base */
--- 417,423 ----
            return pstrdup(r->pool, value); /* no base: use what is given */
          }
        /* no base, no value: pick a simple default */
!       return construct_url(r->pool, "/", r);
      }

      /* must be a relative URL to be combined with base */
*** /tmp/T05K5mO_       Fri Jan 23 13:15:59 1998
--- util.c      Fri Jan 23 13:14:22 1998
***************
*** 808,817 ****
      }
  }

! char *construct_url(pool *p, const char *uri, const server_rec *s) {
!     return pstrcat (p, "http://",
!                   construct_server(p, s->server_hostname, s->port),
!                   uri, NULL);
  }

  #define c2x(what,where) sprintf(where,"%%%02x",(unsigned char)what)
--- 808,826 ----
      }
  }

! char *construct_url(pool *p, const char *uri, const request_rec *r) {
!     char *protocol = "http";
!
! #ifdef APACHE_SSL
!     protocol = pstrcpy(p, http_method(r));
! #endif
!
!     return pstrcat (p, protocol, "://",
!         construct_server(p, r->hostname ? r->hostname
!                                         : r->server->server_hostname,
!                          r->hostname ? ntohs(r->connection->local_addr.sin_port)
!                                      : r->server->port),
!                          uri, NULL);
  }

  #define c2x(what,where) sprintf(where,"%%%02x",(unsigned char)what)

-- 
Michael Douglass
Texas Networking, Inc.

<tnet admin> anyway, I'm off, perl code is making me [a] crosseyed toady

Re: [patch] correctly redirect URLs based on connection information.

Posted by Ben Laurie <be...@algroup.co.uk>.
Michael Douglass wrote:
> 
> On Sat, Jan 24, 1998 at 09:43:52AM +0000, Ben Laurie said:
> 
> > Even better, though, is to define http_method(r) to be "http" for
> > ordinary Apache, then you don't need any conditionals in the code.
> 
> I like that idea alot--it would simplify the coding in mod_rewrite
> as well since the #ifdefs could be removed there too.  It just makes
> "sense". :)

Hmmm ... haven't looked at mod_rewrite lately, but that is certainly how
the rest of Apache-SSL works. Of course, we then get the advantage that
there are no blatant crypto hooks (assuming the NSA have their eyes
closed at this moment).

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: [patch] correctly redirect URLs based on connection information.

Posted by Michael Douglass <mi...@texas.net>.
On Sat, Jan 24, 1998 at 09:43:52AM +0000, Ben Laurie said:

> Even better, though, is to define http_method(r) to be "http" for
> ordinary Apache, then you don't need any conditionals in the code.

I like that idea alot--it would simplify the coding in mod_rewrite
as well since the #ifdefs could be removed there too.  It just makes
"sense". :)

-- 
Michael Douglass
Texas Networking, Inc.

<tnet admin> anyway, I'm off, perl code is making me [a] crosseyed toady

Re: [patch] correctly redirect URLs based on connection information.

Posted by Ben Laurie <be...@algroup.co.uk>.
Michael Douglass wrote:
> 
> On Fri, Jan 23, 1998 at 04:20:48PM -0600, Michael Douglass said:
> 
> > !     char *protocol = "http";
> > !
> > ! #ifdef APACHE_SSL
> > !     protocol = pstrcpy(p, http_method(r));
> > ! #endif
> 
> Doh!  And that should actually be:
> 
> protocol = http_method(r);
> 
> Why am I strcpying it?  Duh... :)

Even better, though, is to define http_method(r) to be "http" for
ordinary Apache, then you don't need any conditionals in the code.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: [patch] correctly redirect URLs based on connection information.

Posted by Michael Douglass <mi...@texas.net>.
On Fri, Jan 23, 1998 at 04:20:48PM -0600, Michael Douglass said:


> !     char *protocol = "http";
> !
> ! #ifdef APACHE_SSL
> !     protocol = pstrcpy(p, http_method(r));
> ! #endif

Doh!  And that should actually be:

protocol = http_method(r);

Why am I strcpying it?  Duh... :)

-- 
Michael Douglass
Texas Networking, Inc.

<tnet admin> anyway, I'm off, perl code is making me [a] crosseyed toady

Re: [patch] correctly redirect URLs based on connection information.

Posted by Michael Douglass <mi...@texas.net>.
On Fri, Jan 23, 1998 at 10:41:29PM +0000, Ben Laurie said:

> Michael Douglass wrote:
> > ! char *construct_url(pool *p, const char *uri, const request_rec *r) {
> > !     char *protocol = "http";
> > !
> > ! #ifdef APACHE_SSL
> > !     protocol = pstrcpy(p, http_method(r));
> > ! #endif
> > !
> > !     return pstrcat (p, protocol, "://",
> > !         construct_server(p, r->hostname ? r->hostname
> > !                                         : r->server->server_hostname,
> > !                          r->hostname ? ntohs(r->connection->local_addr.sin_port)
> > !                                      : r->server->port),
> > !                          uri, NULL);
> 
> Where on Earth did this come from? It's certainly not something I'd
> permit to appear in Apache-SSL.

Which part, the #ifdef APACHE_SSL?  Well, it would be like mod_rewrite.c;
or are you talking about my method of having the pointer there...
Or are you talking about the return statement?  That is a combination of
mine and dean's comments.

I can't fight vagueness.  Which part?? :)

-- 
Michael Douglass
Texas Networking, Inc.

<tnet admin> anyway, I'm off, perl code is making me [a] crosseyed toady

Re: [patch] correctly redirect URLs based on connection information.

Posted by Ben Laurie <be...@algroup.co.uk>.
Michael Douglass wrote:
> ! char *construct_url(pool *p, const char *uri, const request_rec *r) {
> !     char *protocol = "http";
> !
> ! #ifdef APACHE_SSL
> !     protocol = pstrcpy(p, http_method(r));
> ! #endif
> !
> !     return pstrcat (p, protocol, "://",
> !         construct_server(p, r->hostname ? r->hostname
> !                                         : r->server->server_hostname,
> !                          r->hostname ? ntohs(r->connection->local_addr.sin_port)
> !                                      : r->server->port),
> !                          uri, NULL);

Where on Earth did this come from? It's certainly not something I'd
permit to appear in Apache-SSL.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: [patch] correctly redirect URLs based on connection information.

Posted by Dean Gaudet <dg...@arctic.org>.
I've been worrying about the proxy case.  In general in this situation if
it's a proxy not admin'd by the same folks as the origin server then I
don't really care -- the proxy is responsible to get the redirect and
everything right.  But for folks who control both the proxy and the origin
server I think we need to provide an option to enforce the "canonical"
name (i.e. to behave like the current code).  If nobody else beats me to
it I'll add this option and commit Michael's patch at the same time...

Dean

On Fri, 23 Jan 1998, Marc Slemko wrote:

> On Fri, 23 Jan 1998, Michael Douglass wrote:
> 
> > Okay, the word interpretation is up for questioning; but here is a revised
> > patch that incorporates things that were discussed since that point.  Any
> > consideration for adding to 1.3?
> 
> I support the idea, but don't have time to look at the code right now.
> There are docs that have to be updated, and we need to be careful in this
> bit of the code because there are some unintuitive sections.
> 
> Should we ever see a case with a proxy that puts its own Host: header
> in, but that Host: header isn't in the clients DNS, but the ServerName
> would be?  That would mess this up.
> 
> 


Re: [patch] correctly redirect URLs based on connection information.

Posted by Marc Slemko <ma...@worldgate.com>.
On Fri, 23 Jan 1998, Michael Douglass wrote:

> Okay, the word interpretation is up for questioning; but here is a revised
> patch that incorporates things that were discussed since that point.  Any
> consideration for adding to 1.3?

I support the idea, but don't have time to look at the code right now.
There are docs that have to be updated, and we need to be careful in this
bit of the code because there are some unintuitive sections.

Should we ever see a case with a proxy that puts its own Host: header
in, but that Host: header isn't in the clients DNS, but the ServerName
would be?  That would mess this up.