Skip to content

Commit

Permalink
SimpleHTTPServer expects str objects internally so base_url should be…
Browse files Browse the repository at this point in the history
… stored as a str object not a unicode object.
  • Loading branch information
uhnomoli committed Feb 2, 2013
1 parent 416f0ef commit c368c77
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mynt/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, request, client_address, base_url, server):
SimpleHTTPRequestHandler.__init__(self, request, client_address, server)

def do_GET(self):
self.path = self.path.replace(self.base_url, '/').encode('utf-8')
self.path = self.path.replace(self.base_url, b'/')

SimpleHTTPRequestHandler.do_GET(self)

Expand All @@ -40,7 +40,7 @@ class Server(TCPServer):
def __init__(self, server_address, base_url, RequestHandlerClass, bind_and_activate = True):
TCPServer.__init__(self, server_address, RequestHandlerClass, bind_and_activate)

self.base_url = base_url
self.base_url = base_url.encode('utf-8')

def finish_request(self, request, client_address):
self.RequestHandlerClass(request, client_address, self.base_url, self)

2 comments on commit c368c77

@cblte
Copy link

@cblte cblte commented on c368c77 Feb 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you store it as string inside and convert it later, right?

@uhnomoli
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you're asking. SimpleHTTPServer only uses str objects. The only time it gets converted is when the server is initialized.

Please sign in to comment.