mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
missing files
This commit is contained in:
parent
a4685eff77
commit
9b3704e395
35
gunicorn/httpresponse.py
Normal file
35
gunicorn/httpresponse.py
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008,2009 Benoit Chesneau <benoitc@e-engura.org>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
class HTTPResponse(object):
|
||||
|
||||
def __init__(self, req, data):
|
||||
self.req = req
|
||||
self.data = data
|
||||
self.headers = self.req.response_headers or {}
|
||||
self.fp = req.fp
|
||||
|
||||
def write(self, data):
|
||||
self.fp.write(data)
|
||||
|
||||
def send(self):
|
||||
if not self.data: return
|
||||
for chunk in self.data:
|
||||
self.write(chunk)
|
||||
|
||||
|
||||
|
||||
55
gunicorn/socketserver.py
Normal file
55
gunicorn/socketserver.py
Normal file
@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 2008,2009 Benoit Chesneau <benoitc@e-engura.org>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at#
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import socket
|
||||
|
||||
class Socket(socket.socket):
|
||||
def accept_nonblock(self):
|
||||
sock, addr = self.accept()
|
||||
sock.setblocking(0)
|
||||
return (sock, addr)
|
||||
|
||||
|
||||
class TCPServer(Socket):
|
||||
"""class for server-side TCP sockets.
|
||||
This is wrapper around socket.socket class"""
|
||||
|
||||
def __init__(self, address, **opts):
|
||||
self.address = address
|
||||
self.backlog = opts.get('backlog', 1024)
|
||||
self.timeout = opts.get('timeout', 300)
|
||||
self.reuseaddr = opts.get('reuseaddr', True)
|
||||
self.nodelay = opts.get('nodelay', True)
|
||||
self.recbuf = opts.get('recbuf', 8192)
|
||||
|
||||
socket.socket.__init__(self, socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
if self.reuseaddr:
|
||||
self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
|
||||
if self.nodelay:
|
||||
self.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
|
||||
if self.recbuf:
|
||||
self.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF,
|
||||
self.recbuf)
|
||||
|
||||
self.settimeout(self.timeout)
|
||||
self.bind(address)
|
||||
self.listen()
|
||||
|
||||
def listen(self):
|
||||
super(TCPServer, self).listen(self.backlog)
|
||||
Loading…
x
Reference in New Issue
Block a user