This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
roberto@sirius
committed
Mar 31, 2010
1 parent
474860c
commit bdab4dc
Showing
4 changed files
with
156 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import uwsgi | ||
import socket | ||
import errno | ||
|
||
def send_request(env, client): | ||
|
||
client.setblocking(1) | ||
|
||
client.send(b"GET /intl/it_it/images/logo.gif HTTP/1.0\r\n") | ||
client.send(b"Host: www.google.it\r\n\r\n") | ||
|
||
uwsgi.green_schedule() | ||
|
||
while 1: | ||
uwsgi.green_wait_fdread(client.fileno(), 10) | ||
buf = client.recv(4096) | ||
if len(buf) == 0: | ||
break | ||
else: | ||
yield buf | ||
|
||
|
||
def application(env, start_response): | ||
|
||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.setblocking(0) | ||
|
||
c = s.connect_ex(('74.125.77.104', 80)) | ||
if c == errno.EINPROGRESS: | ||
uwsgi.green_wait_fdwrite(s.fileno(), 10) | ||
for r in send_request(env, s): | ||
yield r | ||
elif c == errno.EISCONN: | ||
for r in send_request(env, s): | ||
yield r | ||
else: | ||
uwsgi.green_schedule() | ||
start_response( '500 Internal Server Error', [ ('Content-Type', 'text/html')]) | ||
yield "Internal Server Error" | ||
|
||
s.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters