[prev in list] [next in list] [prev in thread] [next in thread] 

List:       subversion-cvs
Subject:    svn commit: r20902 - trunk/tools/client-side
From:       julianfoad () tigris ! org
Date:       2006-07-29 20:23:06
Message-ID: 20060729202306.9938534C09F () svn ! collab ! net
[Download RAW message or body]

Author: julianfoad
Date: Sat Jul 29 13:23:06 2006
New Revision: 20902

Modified:
   trunk/tools/client-side/server-vsn.py

Log:
In 'server-vsn.py', support 'https:' URLs.  Also handle redirect requests
(302), if the requested resource resides temporarily under a different URL.

Also use better Python APIs.  In httplib, the HTTP and HTTPS functions are
included just for backward compatibility.  Moreover, HTTPS support is only
available if the socket module is compiled with SSL support.  So, use
HTTPConnection and HTTPSConnection functions instead.

Patch by: Bhuvaneswaran Arumugam <bhuvan@collab.net>

* tools/client-side/server-vsn.py
  Do not import "string" library as it is not necessary.
  (print_version): Handle the HTTPS scheme.  Use 'HTTPConnection' and
    'HTTPSConnection' instead of 'HTTP' and 'HTTPS' functions.  Do not
    regard a '302' redirect as an error, use its header info anyway.


Modified: trunk/tools/client-side/server-vsn.py
URL: http://svn.collab.net/viewvc/svn/trunk/tools/client-side/server-vsn.py?pathrev=20902&r1=20901&r2=20902
 ==============================================================================
--- trunk/tools/client-side/server-vsn.py	(original)
+++ trunk/tools/client-side/server-vsn.py	Sat Jul 29 13:23:06 2006
@@ -10,6 +10,8 @@
 # EXAMPLE:
 #
 #   $ ./server-vsn.py http://svn.collab.net/
+#                   or
+#   $ ./server-vsn.py https://svn.collab.net/
 #
 # Python 1.5.2 or later is required.
 #
@@ -17,28 +19,34 @@
 import sys
 import httplib
 import urlparse
-import string
 
 
 def print_version(url):
   scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
-  if scheme != 'http':
-    print 'ERROR: this script only supports "http" URLs'
+  if scheme == 'http':
+    conn = httplib.HTTPConnection(netloc)
+  elif scheme == 'https':
+    conn = httplib.HTTPSConnection(netloc)
+  else:
+    print 'ERROR: this script only supports "http" and "https" URLs'
     sys.exit(1)
-  conn = httplib.HTTP(netloc)
   conn.putrequest('OPTIONS', path)
   conn.putheader('Host', netloc)
   conn.endheaders()
-  status, msg, headers = conn.getreply()
-  if status != 200:
+  resp = conn.getresponse()
+  status, msg, server = (resp.status, resp.msg, resp.getheader('Server'))
+  conn.close()
+
+  # Handle "OK" and Handle redirect requests, if requested resource
+  # resides temporarily under a different URL
+  if status != 200 and status != 302:
     print 'ERROR: bad status response: %s %s' % (status, msg)
     sys.exit(1)
-  server = headers.getheader('Server')
   if not server:
     # a missing Server: header. Bad, bad server! Go sit in the corner!
     print 'WARNING: missing header'
   else:
-    for part in string.split(server):
+    for part in server.split(' '):
       if part[:4] == 'SVN/':
         print part[4:]
         break

---------------------------------------------------------------------
To unsubscribe, e-mail: svn-unsubscribe@subversion.tigris.org
For additional commands, e-mail: svn-help@subversion.tigris.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic