コード例 #1
0
ファイル: proxy.py プロジェクト: p0is0n/arx-proxy
	def sendCode(self, code, message=None):
		if not isinstance(code, (int, long)):
			raise TypeError("HTTP response code must be int or long")
		if not message:
			message = RESPONSES.get(code, "Unknown Status")
		if config.getLogLevel() >= 4:
			log.msg('%s send command "%s"' % (
				self, ('%s %s %s\r\n' % (self._version, code, message))
			))
		self.transport.write('%s %s %s\r\n' % (self._version, code, message))
コード例 #2
0
ファイル: response.py プロジェクト: amogh14/fintra
def response_httprepr(response):
    """Return raw HTTP representation (as string) of the given response. This
    is provided only for reference, since it's not the exact stream of bytes
    that was received (that's not exposed by Twisted).
    """

    s = "HTTP/1.1 %d %s\r\n" % (response.status, RESPONSES.get(response.status, ''))
    if response.headers:
        s += response.headers.to_string() + "\r\n"
    s += "\r\n"
    s += response.body
    return s
コード例 #3
0
def response_httprepr(response):
    """Return raw HTTP representation (as string) of the given response. This
    is provided only for reference, since it's not the exact stream of bytes
    that was received (that's not exposed by Twisted).
    """

    s = "HTTP/1.1 %d %s\r\n" % (response.status, RESPONSES.get(response.status, ''))
    if response.headers:
        s += response.headers.to_string() + "\r\n"
    s += "\r\n"
    s += response.body
    return s
コード例 #4
0
ファイル: response.py プロジェクト: cdingding/scrapy
def response_httprepr(response):
    """Return raw HTTP representation (as bytes) of the given response. This
    is provided only for reference, since it's not the exact stream of bytes
    that was received (that's not exposed by Twisted).
    """
    s = b"HTTP/1.1 " + to_bytes(str(response.status)) + b" " + \
        to_bytes(RESPONSES.get(response.status, b'')) + b"\r\n"
    if response.headers:
        s += response.headers.to_string() + b"\r\n"
    s += b"\r\n"
    s += response.body
    return s
コード例 #5
0
def response_httprepr(response):
    """Return raw HTTP representation (as bytes) of the given response. This
    is provided only for reference, since it's not the exact stream of bytes
    that was received (that's not exposed by Twisted).
    """
    s = b"HTTP/1.1 " + to_bytes(str(response.status)) + b" " + \
        to_bytes(RESPONSES.get(response.status, b'')) + b"\r\n"
    if response.headers:
        s += response.headers.to_string() + b"\r\n"
    s += b"\r\n"
    s += response.body
    return s
コード例 #6
0
ファイル: response.py プロジェクト: Mimino666/crawlmi
 def status_message(self):
     return RESPONSES.get(self.status, '')
コード例 #7
0
ファイル: response.py プロジェクト: dahuangfeng123/crawlmi
 def status_message(self):
     return RESPONSES.get(self.status, '')