httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Terbush <ra...@covalent.net>
Subject [PATCH] setting port in construct_url()
Date Sun, 08 Feb 1998 21:00:48 GMT

I believe that the following is the most logical fix to the
problems we have started seeing redirecting to port 0. This
seems to solve it in the case that I found where this breaks.
I would appreciate a sanity check before commiting this. This
patche also deals with a potentially similar problem in 
get_server_port().


Index: src/main/http_core.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v
retrieving revision 1.156
diff -c -r1.156 http_core.c
*** http_core.c	1998/02/02 22:33:32	1.156
--- http_core.c	1998/02/08 20:52:51
***************
*** 595,608 ****
  
  API_EXPORT(unsigned) get_server_port(const request_rec *r)
  {
      core_dir_config *d =
        (core_dir_config *)get_module_config(r->per_dir_config, &core_module);
      
      if (d->use_canonical_name & 1) {
! 	return r->server->port;
      }
      return r->hostname ? ntohs(r->connection->local_addr.sin_port)
! 			: r->server->port;
  }
  
  API_EXPORT(char *) construct_url(pool *p, const char *uri, const request_rec *r)
--- 595,611 ----
  
  API_EXPORT(unsigned) get_server_port(const request_rec *r)
  {
+     unsigned port;
      core_dir_config *d =
        (core_dir_config *)get_module_config(r->per_dir_config, &core_module);
      
+     port = r->server->port ? r->server->port : default_port(r);
+ 
      if (d->use_canonical_name & 1) {
! 	return port;
      }
      return r->hostname ? ntohs(r->connection->local_addr.sin_port)
! 			: port;
  }
  
  API_EXPORT(char *) construct_url(pool *p, const char *uri, const request_rec *r)
***************
*** 614,625 ****
        (core_dir_config *)get_module_config(r->per_dir_config, &core_module);
  
      if (d->use_canonical_name & 1) {
! 	port = r->server->port;
  	host = r->server->server_hostname;
      }
      else {
! 	port = r->hostname ? ntohs(r->connection->local_addr.sin_port)
! 			    : r->server->port;
  	host = r->hostname ? r->hostname : r->server->server_hostname;
      }
      if (is_default_port(port, r)) {
--- 617,633 ----
        (core_dir_config *)get_module_config(r->per_dir_config, &core_module);
  
      if (d->use_canonical_name & 1) {
! 	port = r->server->port ? r->server->port : default_port(r);
  	host = r->server->server_hostname;
      }
      else {
!         if (r->hostname)
!             port = ntohs(r->connection->local_addr.sin_port);
!         else if (r->server->port)
!             port = r->server->port;
!         else
!             port = default_port(r);
! 
  	host = r->hostname ? r->hostname : r->server->server_hostname;
      }
      if (is_default_port(port, r)) {

Mime
View raw message