Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
d683c243
Commit
d683c243
authored
Jan 24, 2013
by
igor
Committed by
Michael DeHaan
Jan 26, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for user:password syntax in urls to get_url
parent
634d59c9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
library/get_url
+23
-0
No files found.
library/get_url
View file @
d683c243
...
...
@@ -100,6 +100,29 @@ def url_do_get(module, url, dest):
USERAGENT
=
'ansible-httpget'
info
=
dict
(
url
=
url
,
dest
=
dest
)
r
=
None
parsed
=
urlparse
.
urlparse
(
url
)
if
'@'
in
parsed
.
netloc
:
credentials
=
parsed
.
netloc
.
split
(
'@'
)[
0
]
if
':'
in
credentials
:
username
,
password
=
credentials
.
split
(
':'
)
netloc
=
parsed
.
netloc
.
split
(
'@'
)[
1
]
parsed
=
list
(
parsed
)
parsed
[
1
]
=
netloc
passman
=
urllib2
.
HTTPPasswordMgrWithDefaultRealm
()
# this creates a password manager
passman
.
add_password
(
None
,
netloc
,
username
,
password
)
# because we have put None at the start it will always
# use this username/password combination for urls
# for which `theurl` is a super-url
authhandler
=
urllib2
.
HTTPBasicAuthHandler
(
passman
)
# create the AuthHandler
opener
=
urllib2
.
build_opener
(
authhandler
)
urllib2
.
install_opener
(
opener
)
#reconstruct url without credentials
url
=
urlparse
.
urlunparse
(
parsed
)
request
=
urllib2
.
Request
(
url
)
request
.
add_header
(
'User-agent'
,
USERAGENT
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment