Repository navigation
Fixes Chromedriver tests under Windows, by @yahman72 #694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
HelioGuilherme66
wants to merge
2
commits into
robotframework:master
from
HelioGuilherme66:fix_chrome_testing
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,25 @@ | |
| import httplib | ||
| import SimpleHTTPServer | ||
| import BaseHTTPServer | ||
| import socket | ||
|
|
||
|
|
||
| class StoppableHttpRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): | ||
| """http request handler with QUIT stopping the server""" | ||
|
|
||
| def setup(self): | ||
| SimpleHTTPServer.SimpleHTTPRequestHandler.setup(self) | ||
| self.rfile.close() | ||
| self.wfile.close() | ||
| self.rfile = HttpEchoer(self.connection._sock, 'rb', self.rbufsize) | ||
| self.wfile = HttpEchoer(self.connection._sock, 'wb', self.wbufsize) | ||
|
|
||
| def do_QUIT(self): | ||
| """send 200 OK response, and set server.stop to True""" | ||
| self.send_response(200) | ||
| self.end_headers() | ||
| self.server.stop = True | ||
|
|
||
| def do_POST(self): | ||
| # We could also process paremeters here using something like below. | ||
| # length = self.headers['Content-Length'] | ||
|
|
@@ -63,7 +71,11 @@ def send_head(self): | |
| self.send_response(200) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two empty lines before the class definition |
||
| self.send_header("Content-type", ctype) | ||
| fs = os.fstat(f.fileno()) | ||
| self.send_header("Content-Length", str(fs[6])) | ||
| # chrome hangs if this server runs on windows | ||
| # it probably waits for more data -> os.fstat() does not return correct | ||
| # length? We are responding with HTTP 1.0 = we do not need | ||
| # content-length header: | ||
| # self.send_header("Content-Length", str(fs[6])) | ||
| self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) | ||
| self.end_headers() | ||
| return f | ||
|
|
@@ -79,6 +91,33 @@ def serve_forever(self): | |
| self.handle_request() | ||
|
|
||
|
|
||
| class HttpEchoer(socket._fileobject): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two empty lines before the class definition |
||
| # echoes all HTTP traffic to a file if | ||
| # the server output is set to a file in run_tests.py | ||
| def read(self, size=-1): | ||
| data = super(HttpEchoer, self).read(size) | ||
| sys.stdout.write("-->: %s" % data) | ||
| sys.stdout.flush() | ||
| return data | ||
|
|
||
| def readline(self, size=-1): | ||
| data = super(HttpEchoer, self).readline(size) | ||
| sys.stdout.write("-->: %s" % data) | ||
| sys.stdout.flush() | ||
| return data | ||
|
|
||
| def readlines(self, sizehint=0): | ||
| data = super(HttpEchoer, self).readlines(sizehint) | ||
| sys.stdout.write("-->: %s" % data) | ||
| sys.stdout.flush() | ||
| return data | ||
|
|
||
| def write(self, data): | ||
| sys.stdout.write("<--: %s" % data) | ||
| sys.stdout.flush() | ||
| super(HttpEchoer, self).write(data) | ||
|
|
||
|
|
||
| def stop_server(port=7000): | ||
| """send QUIT request to http server running on localhost:<port>""" | ||
| conn = httplib.HTTPConnection("localhost:%d" % port) | ||
|
|
@@ -91,8 +130,7 @@ def start_server(port=7000): | |
| os.chdir(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), '..')) | ||
| server = StoppableHttpServer(('', port), StoppableHttpRequestHandler) | ||
| server.serve_forever() | ||
|
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| import sys | ||
| if len(sys.argv) != 2 or sys.argv[1] not in ['start', 'stop']: | ||
|
|
@@ -102,5 +140,3 @@ def start_server(port=7000): | |
| start_server() | ||
| else: | ||
| stop_server() | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two empty lines before the class definition