Skip to content

Conversation

@jobala
Copy link
Contributor

@jobala jobala commented Mar 2, 2020

Overview

The HTTPClientFactory creates an instance of requests with;

  • middleware support
  • base url -- https://graph.microsoft.com/v1.0
  • default sdkVersion header

How the API works

from msgraph_sdk_python import HTTPClientFactory

requests = HTTPClientFactory.with_graph_middlewares(middlewares)

response = requests.get('/me')

Support for proxies

requests.proxies = {
   'http': 'http://localhost:3000',
    'https': 'http://localhost:3000'
}

GZIP compression

Not supported out of the box, will be implemented as a middleware

Enforcing TLS 1.2

Can be done through a HTTPAdapter.
https://lukasa.co.uk/2013/01/Choosing_SSL_Version_In_Requests/
Tracked in #2

return _HTTPClient(middlewares=middlewares)


class _HTTPClient(Session):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_HTTPClient [](start = 6, length = 11)

shouldn't this just be HTTPClient?

Copy link
Contributor Author

@jobala jobala Mar 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python compensates for lack of access modifiers with prefixing private fields/classes with an underscore.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so your intent here is that everything is always called through the factory and there are no guarantees made that _HTTPClient wouldn't break in some non-compatible way. I see your point but at the same time callers will work directly against this class and it's not completely abstracted in the library so there'd be some back compat expectations.

@jobala jobala marked this pull request as ready for review March 3, 2020 10:03
@jobala jobala merged commit a57a9ae into dev Mar 13, 2020
@samwelkanda samwelkanda deleted the feat/http-client-factory branch October 14, 2022 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants