Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow easier access to site on a http:// URL #212

Closed
mtausig opened this issue Jan 9, 2019 · 9 comments · Fixed by #213
Closed

Allow easier access to site on a http:// URL #212

mtausig opened this issue Jan 9, 2019 · 9 comments · Fixed by #213

Comments

@mtausig
Copy link
Contributor

mtausig commented Jan 9, 2019

Currently, the URL scheme used to access the MediaWiki instance is hardcoded to https in the raw_call function of client.py. This makes it impossible to use mwclient wit a wiki which is hosted under an unencrypted http:// URL.

This should be made configurable (either by adding a scheme parameter to the Site constructor or by allowing a full URL instead of just the hostname there).

@tosher
Copy link
Contributor

tosher commented Jan 9, 2019

https://mwclient.readthedocs.io/en/latest/user/connecting.html#connecting-to-your-site

By default, mwclient will connect using https. If your site doesn’t support https, you need to explicitly request http like so:

site = Site(('http', 'test.wikipedia.org'))

@mtausig
Copy link
Contributor Author

mtausig commented Jan 10, 2019

Apologies. I went straight to the reference documentation of the Site class and missed this info.

@mtausig mtausig closed this as completed Jan 10, 2019
@waldyrious
Copy link
Member

waldyrious commented Jan 10, 2019

Wouldn't a specific parameter be a neater way to achieve this, instead of relying on a specific, opaque data structure and the custom code to handle it?

mwclient/mwclient/client.py

Lines 367 to 370 in 030cf8a

scheme = 'https'
host = self.host
if isinstance(host, (list, tuple)):
scheme, host = host

This entire bit could be removed if host and scheme were always assigned individually (with scheme defaulting to "https", of course). That's cleaner both implementation-wise and in terms of a consistent, self-documenting API, no?

@tosher
Copy link
Contributor

tosher commented Jan 10, 2019

#198

@waldyrious
Copy link
Member

Thanks for cross-referencing that PR, @tosher. I think the comment above still stands.

@danmichaelo
Copy link
Member

Wouldn't a specific parameter be a neater way to achieve this, instead of relying on a specific, opaque data structure and the custom code to handle it?

I've only kept it for backwards compatibility, but I wouldn't mind if we introduced a new parameter and deprecated the old syntax and then removed it with the next major release or something.

@waldyrious
Copy link
Member

@danmichaelo shall we reopen #213 then (and this issue as well), provided that it also removes the special handling of the host parameter in the code I quoted above?

@danmichaelo
Copy link
Member

Yup, just re-opened #213. But perhaps keep this issue closed? At least with the current title ("Allow access to site on a http:// URL")

@mtausig mtausig changed the title Allow access to site on a http:// URL Allow easier access to site on a http:// URL Jan 27, 2019
@mtausig
Copy link
Contributor Author

mtausig commented Jan 27, 2019

Yup, just re-opened #213. But perhaps keep this issue closed? At least with the current title ("Allow access to site on a http:// URL")

Better now?

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 a pull request may close this issue.

4 participants