1
1
# -*- coding: utf-8 -*-
2
2
from __future__ import unicode_literals
3
3
4
+ from abc import ABCMeta , abstractmethod
5
+ from future .utils import with_metaclass
4
6
import requests
5
7
6
8
7
- class HttpClient (object ):
9
+ class HttpClient (with_metaclass ( ABCMeta ) ):
8
10
DEFAULT_TIMEOUT = 5
9
11
10
12
def __init__ (self , timeout = DEFAULT_TIMEOUT ):
@@ -17,6 +19,7 @@ def __init__(self, timeout=DEFAULT_TIMEOUT):
17
19
18
20
self .timeout = timeout
19
21
22
+ @abstractmethod
20
23
def get (self , url , headers = None , params = None , timeout = None ):
21
24
"""GET request
22
25
@@ -30,6 +33,7 @@ def get(self, url, headers=None, params=None, timeout=None):
30
33
"""
31
34
raise NotImplementedError
32
35
36
+ @abstractmethod
33
37
def get_stream (self , url , headers = None , params = None , timeout = None ,
34
38
chunk_size = 1024 , decode_unicode = False ):
35
39
"""GET request. response is chunk content.
@@ -45,6 +49,7 @@ def get_stream(self, url, headers=None, params=None, timeout=None,
45
49
"""
46
50
raise NotImplementedError
47
51
52
+ @abstractmethod
48
53
def post (self , url , headers = None , data = None , timeout = None ):
49
54
"""POST request.
50
55
0 commit comments