示例#1
0
 def get(self, path, query=None):
     url = self._baseurl.copy()
     url.path = self._baseurl.path + path
     headers = [httputils.Referer(self._baseurl), httputils.Connection("keep-alive")]
     request = HTTPRequest(url, method="GET", query=query, cookiejar=self._cookiejar, extraheaders=headers)
     resp = request.perform(self._logfile)
     if resp.status.code != 200:
         raise RequestResponseError(str(resp.status))
     self._cookiejar.parse_mozilla_lines(resp.cookielist)
     return resp
示例#2
0
 def post(self, path, data, query=None):
     url = self._baseurl.copy()
     url.path = self._baseurl.path + path
     if query:
         url.query = query
     request = HTTPRequest(url, data, method="POST", cookiejar=self._cookiejar,
             accept="application/json")
     resp = request.perform(self._logfile)
     if resp.status.code != 200:
         raise RequestResponseError(str(resp.status))
     self._cookiejar.parse_mozilla_lines(resp.cookielist)
     return resp
示例#3
0
 def post(self, path, data, query=None):
     url = self._baseurl.copy()
     url.path = self._baseurl.path + path
     if query:
         url.query = query
     request = HTTPRequest(url,
                           data,
                           method="POST",
                           cookiejar=self._cookiejar,
                           accept="application/json")
     resp = request.perform(self._logfile)
     if resp.status.code != 200:
         raise RequestResponseError(str(resp.status))
     self._cookiejar.parse_mozilla_lines(resp.cookielist)
     return resp
示例#4
0
 def get(self, path, query=None):
     url = self._baseurl.copy()
     url.path = self._baseurl.path + path
     headers = [
         httputils.Referer(self._baseurl),
         httputils.Connection("keep-alive")
     ]
     request = HTTPRequest(url,
                           method="GET",
                           query=query,
                           cookiejar=self._cookiejar,
                           extraheaders=headers)
     resp = request.perform(self._logfile)
     if resp.status.code != 200:
         raise RequestResponseError(str(resp.status))
     self._cookiejar.parse_mozilla_lines(resp.cookielist)
     return resp