forked from grpc/grpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Server for httpcli_test""" | ||
|
||
import argparse | ||
import BaseHTTPServer | ||
|
||
argp = argparse.ArgumentParser(description='Server for httpcli_test') | ||
argp.add_argument('-p', '--port', default=10080, type=int) | ||
args = argp.parse_args() | ||
|
||
print 'server running on port %d' % args.port | ||
|
||
class Handler(BaseHTTPServer.BaseHTTPRequestHandler): | ||
def good(self): | ||
self.send_response(200) | ||
self.send_header('Content-Type', 'text/html') | ||
self.end_headers() | ||
self.wfile.write('<html><head><title>Hello world!</title></head>') | ||
self.wfile.write('<body><p>This is a test</p></body></html>') | ||
|
||
def do_GET(self): | ||
if self.path == '/get': | ||
self.good() | ||
|
||
def do_POST(self): | ||
content = self.rfile.read(int(self.headers.getheader('content-length'))) | ||
if self.path == '/post' and content == 'hello': | ||
self.good() | ||
|
||
BaseHTTPServer.HTTPServer(('', args.port), Handler).serve_forever() |
This file contains 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