Skip to content

Commit 49dd649

Browse files
committed
change reposne code
1 parent 3478ae4 commit 49dd649

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

server/gae/gae.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ def application(environ, start_response):
103103
if environ['REQUEST_METHOD'] == 'GET' and not ps_headers:
104104
timestamp = long(os.environ['CURRENT_VERSION_ID'].split('.')[1])/2**28
105105
ctime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(timestamp+8*3600))
106-
html = u'GoAgent Python Server %s \u5df2\u7ecf\u5728\u5de5\u4f5c\u4e86\uff0c\u90e8\u7f72\u65f6\u95f4 %s\n' % (__version__, ctime)
106+
text = u'GoAgent Python Server %s \u5df2\u7ecf\u5728\u5de5\u4f5c\u4e86\uff0c\u90e8\u7f72\u65f6\u95f4 %s\n' % (__version__, ctime)
107107
start_response('200 OK', [('Content-Type', 'text/plain; charset=utf-8')])
108-
yield html.encode('utf8')
108+
yield text.encode('utf8')
109109
raise StopIteration
110110

111111
if 'rc4' in options and not __password__:
112-
start_response('400 Bad Request', [('Content-Type', 'text/html')])
112+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
113113
yield message_html('400 Bad Request', 'Bad Request (options) - please set __password__ in gae.py', 'please set __password__ and upload gae.py again')
114114
raise StopIteration
115115

@@ -130,7 +130,7 @@ def application(environ, start_response):
130130
url = headers.pop('G-Url')
131131
except (zlib.error, KeyError, ValueError):
132132
import traceback
133-
start_response('500 Internal Server Error', [('Content-Type', 'text/html')])
133+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
134134
yield message_html('500 Internal Server Error', 'Bad Request (metadata) - Possible Wrong Password', '<pre>%s</pre>' % traceback.format_exc())
135135
raise StopIteration
136136

@@ -147,31 +147,31 @@ def application(environ, start_response):
147147
#logging.info('request headers=%s', headers)
148148

149149
if __password__ and __password__ != kwargs.get('password', ''):
150-
start_response('403 Forbidden', [('Content-Type', 'text/html')])
150+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
151151
yield message_html('403 Wrong password', 'Wrong password(%r)' % kwargs.get('password', ''), 'GoAgent proxy.ini password is wrong!')
152152
raise StopIteration
153153

154154
netloc = urlparse.urlparse(url).netloc
155155

156156
if __hostsdeny__ and netloc.endswith(__hostsdeny__):
157-
start_response('403 Forbidden', [('Content-Type', 'text/html')])
157+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
158158
yield message_html('403 Hosts Deny', 'Hosts Deny(%r)' % netloc, detail='url=%r' % url)
159159
raise StopIteration
160160

161161
if len(url) > MAX_URL_LENGTH:
162-
start_response('400 Bad Request', [('Content-Type', 'text/html')])
162+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
163163
yield message_html('400 Bad Request', 'length of URL too long(greater than %r)' % MAX_URL_LENGTH, detail='url=%r' % url)
164164
raise StopIteration
165165

166166
if netloc.startswith(('127.0.0.', '::1', 'localhost')):
167-
start_response('400 Bad Request', [('Content-Type', 'text/html')])
167+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
168168
html = ''.join('<a href="https://%s/">%s</a><br/>' % (x, x) for x in ('google.com', 'mail.google.com'))
169169
yield message_html('GoAgent %s is Running' % __version__, 'Now you can visit some websites', html)
170170
raise StopIteration
171171

172172
fetchmethod = getattr(urlfetch, method, None)
173173
if not fetchmethod:
174-
start_response('405 Method Not Allowed', [('Content-Type', 'text/html')])
174+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
175175
yield message_html('405 Method Not Allowed', 'Method Not Allowed: %r' % method, detail='Method Not Allowed URL=%r' % url)
176176
raise StopIteration
177177

@@ -217,7 +217,7 @@ def application(environ, start_response):
217217
if i == 0 and method == 'GET':
218218
deadline = URLFETCH_TIMEOUT * 2
219219
else:
220-
start_response('500 Internal Server Error', [('Content-Type', 'text/html')])
220+
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
221221
error_string = '<br />\n'.join(errors)
222222
if not error_string:
223223
logurl = 'https://appengine.google.com/logs?&app_id=%s' % os.environ['APPLICATION_ID']

0 commit comments

Comments
 (0)