Changeset - 851ea1139169
[Not reviewed]
beta
0 1 0
Tony Bussieres - 14 years ago 2012-02-28 02:35:12
t.bussieres@gmail.com
Transplanted from: f06759dca601
No more relying on user agent to check if the request is for a git action. Patch candidate for issue #368
1 file changed with 6 insertions and 17 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/middleware/simplegit.py
Show inline comments
 
@@ -83,22 +83,15 @@ log = logging.getLogger(__name__)
 
GIT_PROTO_PAT = re.compile(r'git-upload-pack|git-receive-pack|info\/refs')
 

	
 

	
 
def is_git(environ):
 
    """Returns True if request's target is git server.
 
    ``HTTP_USER_AGENT`` would then have git client version given.
 

	
 
    :param environ:
 
    """
 
    http_user_agent = environ.get('HTTP_USER_AGENT')
 
    if http_user_agent and http_user_agent.startswith('git'):
 
        return True
 
    return False
 

	
 

	
 
class SimpleGit(BaseVCSController):
 

	
 
    def _handle_request(self, environ, start_response):
 
        if not is_git(environ):
 
        #======================================================================
 
        # GET ACTION PULL or PUSH
 
        #======================================================================
 
        action = self.__get_action(environ)
 

	
 
        if not action in ['pull','push']:
 
            return self.application(environ, start_response)
 

	
 
        proxy_key = 'HTTP_X_REAL_IP'
 
@@ -117,10 +110,6 @@ class SimpleGit(BaseVCSController):
 
        except:
 
            return HTTPInternalServerError()(environ, start_response)
 

	
 
        #======================================================================
 
        # GET ACTION PULL or PUSH
 
        #======================================================================
 
        action = self.__get_action(environ)
 

	
 
        #======================================================================
 
        # CHECK ANONYMOUS PERMISSION
0 comments (0 inline, 0 general)