You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU> on 1997/03/29 09:19:52 UTC

[PATCH] Correct status when POSTing to bad URL, proxy to origin

The following (much easier than expected) patch fixes the problems of
getting the wrong status (405 Method Not Allowed) when POST is sent to
a nonexistant URL, and the wrong status (501 Method Not Implemented)
when any method is sent with a full-URI that doesn't match the server
and the server is not acting as a proxy.

>  * wrong response to proxy request without proxy
>	<97...@paris.ics.uci.edu>

These are just simple protocol errors that have caused a lot of
user confusion in the past (see PR 280, for example).

....Roy

Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.74
diff -c -r1.74 http_core.c
*** http_core.c	1997/03/11 03:41:42	1.74
--- http_core.c	1997/03/29 07:59:52
***************
*** 1264,1270 ****
      void *sconf = r->server->module_config;
      core_server_config *conf = get_module_config (sconf, &core_module);
    
!     if (r->proxyreq) return NOT_IMPLEMENTED;
      if ((r->uri[0] != '/') && strcmp(r->uri, "*")) return BAD_REQUEST;
      
      if (r->server->path &&
--- 1264,1270 ----
      void *sconf = r->server->module_config;
      core_server_config *conf = get_module_config (sconf, &core_module);
    
!     if (r->proxyreq) return HTTP_FORBIDDEN;
      if ((r->uri[0] != '/') && strcmp(r->uri, "*")) return BAD_REQUEST;
      
      if (r->server->path &&
***************
*** 1303,1309 ****
  
      if (r->method_number == M_INVALID) return NOT_IMPLEMENTED;
      if (r->method_number == M_OPTIONS) return send_http_options(r);
!     if (r->method_number != M_GET) return METHOD_NOT_ALLOWED;
  
      if (r->finfo.st_mode == 0 || (r->path_info && *r->path_info)) {
  	log_reason("File does not exist",
--- 1303,1309 ----
  
      if (r->method_number == M_INVALID) return NOT_IMPLEMENTED;
      if (r->method_number == M_OPTIONS) return send_http_options(r);
!     if (r->method_number == M_PUT) return METHOD_NOT_ALLOWED;
  
      if (r->finfo.st_mode == 0 || (r->path_info && *r->path_info)) {
  	log_reason("File does not exist",
***************
*** 1311,1316 ****
--- 1311,1317 ----
  		: r->filename, r);
  	return NOT_FOUND;
      }
+     if (r->method_number != M_GET) return METHOD_NOT_ALLOWED;
  	
      if ((errstatus = set_last_modified (r, r->finfo.st_mtime))
  	|| (errstatus = set_content_length (r, r->finfo.st_size)))

Re: [PATCH] Correct status when POSTing to bad URL, proxy to origin

Posted by Chuck Murcko <ch...@topsail.org>.
Roy T. Fielding wrote:
> 
> The following (much easier than expected) patch fixes the problems of
> getting the wrong status (405 Method Not Allowed) when POST is sent to
> a nonexistant URL, and the wrong status (501 Method Not Implemented)
> when any method is sent with a full-URI that doesn't match the server
> and the server is not acting as a proxy.
> 
> >  * wrong response to proxy request without proxy
> >       <97...@paris.ics.uci.edu>
> 
> These are just simple protocol errors that have caused a lot of
> user confusion in the past (see PR 280, for example).
> 
+1. Works here.
-- 
chuck
Chuck Murcko
The Topsail Group, West Chester PA USA
chuck@topsail.org