Skip to content

Commit

Permalink
added auth
Browse files Browse the repository at this point in the history
  • Loading branch information
keredson committed Aug 11, 2020
1 parent f038c2b commit 74413e4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions boddle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import io
import json as lib_json
from base64 import b64encode


try:
import bottle
Expand All @@ -16,17 +18,21 @@
from urllib.parse import urlparse, urlencode


__version__ = '0.2.8'
__version__ = '0.2.9'


class boddle(object):

def __init__(self, params={}, path=None, method=None, headers=None, json=None, url=None, body=None, query={}, **extras):
def __init__(self, params={}, path=None, method=None, headers=None, json=None, url=None, body=None, query={}, auth=None, **extras):

environ = {}
self.extras = extras
self.extra_orig = {}
self.orig_app_reader = bottle.BaseRequest.app

if auth is not None:
user, password = auth
environ["HTTP_AUTHORIZATION"] = "Basic {}".format(b64encode(bytes(f"{user}:{password}", "utf-8")).decode("ascii"))

if params is not None:
self._set_payload(environ, urlencode(params).encode('utf8'))
Expand Down

0 comments on commit 74413e4

Please sign in to comment.