Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nanwu committed Dec 28, 2015
1 parent a24ab06 commit 5125b76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 2 additions & 5 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
cli = Client('127.0.01', 1080)
cli.connect(('www.google.com', 80))
cli.sendall(
b'GET /HTTP/1.1\n'
b'Host: [rsid].112.2o7.net\n'
b'Keep-Alive: timeout=15\n'
b'Connection: Keep-Alive\n'
b'X-Forwarded-For: 192.168.10.1\n')
b'GET / HTTP/1.1\n'
b'Host: www.google.com\n\n')
print(cli.recvall())
8 changes: 3 additions & 5 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
STATUS_CONN_ESTABLISHED = 3


BUFF_SIZE = 1024
BUFF_SIZE = 1024*1024

class Client:

Expand Down Expand Up @@ -77,14 +77,13 @@ def connect(self, dest):

def sendall(self, _bytes):
data_length = self._socket.sendall(_bytes)
print(data_length)


def recvall(self):
data = b''
import pdb; pdb.set_trace()
while True:
frag = self._socket.recv(BUFF_SIZE)
if not frag:
if len(frag) == 0:
break
data += frag
return data
Expand All @@ -101,7 +100,6 @@ def _send_conn_request(self, dest):
self._socket.send(request_content)

def _recv_conn_reponse(self):
import pdb;pdb.set_trace()
res = self._socket.recv(255) # to be verified
# check version
ver, res = res[:1], res[1:]
Expand Down

0 comments on commit 5125b76

Please sign in to comment.