Commits

Dominik Ruf committed 9d64ab3

fix issue #2

  • Participants
  • Parent commits fbfe906

Comments (0)

Files changed (1)

hgssoauthentication.py

         import kerberos
     except ImportError, e:
         raise ImportError('Neigther sspi nor kerberos module is available')
-
+
+
 class SSPIAuthHandler(urllib2.BaseHandler):
     """auth handler for urllib2 that does Kerberos/NTLM/SSPI HTTP Negotiate Authentication
     """
     
-    handler_order = 480 # TODO: test this by enabling basic auth 
+    handler_order = 480  # TODO: test this by enabling basic auth
     
     def __init__(self, ui, passmgr):
         pass
             auth = encodestring(data).replace("\012", "")
             req.add_header('Authorization', 'Negotiate' + ' ' + auth)
             return self.parent.open(req)
-            
+
         elif('NTLM' in supported_schemes):
             # 1. request
             ca = ClientAuth("NTLM", auth_info=None)
             data = out_buf[0].Buffer
             
             auth = encodestring(data).replace("\012", "")
-            h.putrequest('GET', req._Request__r_host)
+            h.putrequest(req.get_method(), req._Request__r_host)
+
             h.putheader('Authorization', auth_scheme + ' ' + auth)
-            h.putheader('Content-Length', '0')
             for e in req.unredirected_hdrs.items() + req.headers.items():
-                if(e[0] != 'Host'):
+                if e[0] != 'Host':
                     h.putheader(e[0], e[1])
             h.endheaders()
+
+            if req.has_data() and req.data != '':
+                req.data.seek(0)
+                mydata = req.data.read()
+                h.send(mydata)
+
             resp = h.getresponse()
-            
             fp.headers = resp.msg
             fp.read = resp.read
             return fp
         mercurial.url.handlerfuncs.append(SSPIAuthHandler)
     elif('kerberos' in globals()):
         mercurial.url.handlerfuncs.append(KerberosAuthHandler)
-