Advertisement
Guest User

illume

a guest
Sep 19th, 2009
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. 115,119c115,119
  2. < from cStringIO import StringIO
  3. < from Queue import Queue
  4. < regex_head = re.compile('^((http|https|HTTP|HTTPS)\://[^/]+)?(?P<method>\w+)\s+(?P<uri>\S+)\s+(?P<protocol>\S+)')
  5. < regex_header = re.compile('\s*(?P<key>.*?)\s*\:\s*(?P<value>.*?)\s*$')
  6. < regex_chunk = re.compile('^(?P<size>\w+)')
  7. ---
  8. > from io import StringIO
  9. > from queue import Queue
  10. > regex_head = re.compile(b'^((http|https|HTTP|HTTPS)\://[^/]+)?(?P<method>\w+)\s+(?P<uri>\S+)\s+(?P<protocol>\S+)')
  11. > regex_header = re.compile(b'\s*(?P<key>.*?)\s*\:\s*(?P<value>.*?)\s*$')
  12. > regex_chunk = re.compile(b'^(?P<size>\w+)')
  13. 216c216
  14. < break
  15. ---
  16. > break
  17. 231c231
  18. < uri = match.group('uri')
  19. ---
  20. > uri = str(match.group('uri'))
  21. 252c252
  22. < if line == '\r\n':
  23. ---
  24. > if line == b'\r\n':
  25. 257,260c257,258
  26. < key = match.group('key').upper().replace('-','_')
  27. < if isinstance(key,unicode):
  28. < key = key.encode('ISO-8859-1')
  29. < value = match.group('value')
  30. ---
  31. > key = str(match.group('key')).upper().replace('-','_')
  32. > value = str(match.group('value'))
  33. 290c288
  34. < headers.append(('Content-Length',len(data_items[0])))
  35. ---
  36. > headers.append(('Content-Length',len(bytes(data_items[0],'utf8'))))
  37. 296c294
  38. < client_socket.sendall(data)
  39. ---
  40. > client_socket.sendall(bytes(data,'utf8'))
  41. 300c298
  42. < client_socket.sendall('%x\r\n%s\r\n' % (len(data),data))
  43. ---
  44. > client_socket.sendall(bytes('%x\r\n%s\r\n' % (len(data),data),'utf8'))
  45. 302,303c300,301
  46. < client_socket.sendall(data)
  47. < except socket.error, e:
  48. ---
  49. > client_socket.sendall(bytes(data,'utf8'))
  50. > except socket.error as e:
  51. 307c305
  52. < client_socket.sendall('0\r\n')
  53. ---
  54. > client_socket.sendall(b'0\r\n')
  55. 315c313
  56. < "HTTP/1.0 %s\r\nContent-Length: 0\r\nContent-Type: text/plain\r\n\r\n" % status)
  57. ---
  58. > b"HTTP/1.0 %s\r\nContent-Length: 0\r\nContent-Type: text/plain\r\n\r\n" % status)
  59. 386c384
  60. < print 'Experimental "Sneaky" WSGI web server. Starting...'
  61. ---
  62. > print ('Experimental "Sneaky" WSGI web server. Starting...')
  63. 457c455
  64. < print 'serving from: '+address
  65. ---
  66. > print ('serving from: '+address)
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement