Changeset 39 for trunk/bin/bletchley-http2py
- Timestamp:
- 02/16/13 21:12:12 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/bletchley-http2py
r28 r39 15 15 16 16 17 Copyright (C) 2011-201 2Virtual Security Research, LLC17 Copyright (C) 2011-2013 Virtual Security Research, LLC 18 18 Author: Timothy D. Morgan 19 19 … … 64 64 65 65 66 print('''#!/usr/bin/env python67 68 import sys69 # function with either Python 2.7 or 3.x70 try:71 import http.client as httpc72 except:73 import httplib as httpc74 ''')75 76 66 77 67 if '\r\n\r\n' in input_req: … … 110 100 'accept-encoding','accept-charset', 111 101 'connection', 'keep-alive', 'host', 112 'content-length' ]:102 'content-length', 'proxy-connection']: 113 103 headers.append((name,[value])) 114 104 … … 121 111 host = value 122 112 113 114 print('''#!/usr/bin/env python 115 116 import sys 117 # function with either Python 2.7 or 3.x 118 try: 119 import http.client as httpc 120 except: 121 import httplib as httpc 122 ''') 123 124 123 125 print(''' 124 126 # TODO: ensure the host, port, and SSL settings are correct. … … 129 131 130 132 chunked_body = '\n '.join([repr(body[i:i+40]) for i in range(0,len(body),40)]) 133 if chunked_body == '': 134 chunked_body = "''" 131 135 132 136 print(''' 133 def sendRequest(connection): 137 # TODO: use "data" to supply any parameters to be included in the request 138 def sendRequest(connection, data=None): 134 139 method = %s 135 140 path = %s … … 155 160 156 161 157 connection = None 158 if use_ssl: 159 connection = httpc.HTTPSConnection(host, port) 160 else: 161 connection = httpc.HTTPConnection(host, port) 162 def newConnection(): 163 connection = None 164 if use_ssl: 165 return httpc.HTTPSConnection(host, port) 166 else: 167 return httpc.HTTPConnection(host, port) 162 168 163 # TODO: customize code here to retrieve what you need from the response(s)164 # For information on the response object's interface, see:165 # http://docs.python.org/library/httplib.html#httpresponse-objects166 169 167 connection.connect() 168 response = sendRequest(connection) 169 print(response.getheaders()) 170 print(repr(response.read())) 171 connection.close() 170 def fetch(data): 171 ret_val = None 172 connection = newConnection() 173 174 # TODO: customize code here to retrieve what you need from the response(s) 175 # For information on the response object's interface, see: 176 # http://docs.python.org/library/httplib.html#httpresponse-objects 177 response = sendRequest(connection, data) 178 print(response.getheaders()) 179 print(repr(response.read())) 180 181 connection.close() 182 return ret_val 183 184 data = '' 185 fetch(data) 172 186 ''')
Note: See TracChangeset
for help on using the changeset viewer.