Changeset 47 for trunk/bin/bletchley-http2py
- Timestamp:
- 05/30/13 12:36:53 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/bletchley-http2py
r40 r47 35 35 import sys 36 36 import argparse 37 38 bopen = lambda f: open(f, 'rb') 37 39 38 40 parser = argparse.ArgumentParser( … … 43 45 ' For more information, see: http://code.google.com/p/bletchley/wiki/Overview') 44 46 parser.add_argument( 45 'requestfile', type= open, nargs='?', default=sys.stdin,47 'requestfile', type=bopen, nargs='?', default=sys.stdin.buffer, 46 48 help='A file containing an HTTP request. Defaults to stdin if omitted.') 47 49 parser.add_argument( … … 53 55 54 56 55 if '\r\n\r\n' in input_req:56 raw_headers,body = input_req.split( '\r\n\r\n', 1)57 elif '\n\n' in input_req:58 raw_headers,body = input_req.split( '\n\n', 1)57 if b'\r\n\r\n' in input_req: 58 raw_headers,body = input_req.split(b'\r\n\r\n', 1) 59 elif b'\n\n' in input_req: 60 raw_headers,body = input_req.split(b'\n\n', 1) 59 61 else: 60 62 raw_headers = input_req 61 body = '' 63 body = b'' 64 65 raw_headers = raw_headers.decode('utf-8') 62 66 63 67 header_lines = raw_headers.split('\n') … … 102 106 103 107 104 formatted_body = '\n '.join([repr(body[i:i+40] .encode()) for i in range(0,len(body),40)])105 if formatted_body == '':108 formatted_body = '\n '.join([repr(body[i:i+40]) for i in range(0,len(body),40)]) 109 if formatted_body == b'': 106 110 formatted_body = "b''" 107 111
Note: See TracChangeset
for help on using the changeset viewer.