MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / HttpAuthenticated

Class HttpAuthenticated

suds/transport/http.py:164–188  ·  view source on GitHub ↗

Provides basic http authentication for servers that don't follow the specified challenge / response model. This implementation appends the I{Authorization} http header with base64 encoded credentials on every http request.

Source from the content-addressed store, hash-verified

162
163
164class HttpAuthenticated(HttpTransport):
165 """
166 Provides basic http authentication for servers that don't follow
167 the specified challenge / response model. This implementation
168 appends the I{Authorization} http header with base64 encoded
169 credentials on every http request.
170 """
171
172 def open(self, request):
173 self.addcredentials(request)
174 return HttpTransport.open(self, request)
175
176 def send(self, request):
177 self.addcredentials(request)
178 return HttpTransport.send(self, request)
179
180 def addcredentials(self, request):
181 credentials = self.credentials()
182 if not (None in credentials):
183 encoded = b64encode(':'.join(credentials).encode('utf-8')).decode("ascii")
184 basic = 'Basic %s' % encoded
185 request.headers['Authorization'] = basic
186
187 def credentials(self):
188 return (self.options.username, self.options.password)

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected