@@ -103,13 +103,13 @@ def application(environ, start_response):
103
103
if environ ['REQUEST_METHOD' ] == 'GET' and not ps_headers :
104
104
timestamp = long (os .environ ['CURRENT_VERSION_ID' ].split ('.' )[1 ])/ 2 ** 28
105
105
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 )
107
107
start_response ('200 OK' , [('Content-Type' , 'text/plain; charset=utf-8' )])
108
- yield html .encode ('utf8' )
108
+ yield text .encode ('utf8' )
109
109
raise StopIteration
110
110
111
111
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 ' )])
113
113
yield message_html ('400 Bad Request' , 'Bad Request (options) - please set __password__ in gae.py' , 'please set __password__ and upload gae.py again' )
114
114
raise StopIteration
115
115
@@ -130,7 +130,7 @@ def application(environ, start_response):
130
130
url = headers .pop ('G-Url' )
131
131
except (zlib .error , KeyError , ValueError ):
132
132
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 ' )])
134
134
yield message_html ('500 Internal Server Error' , 'Bad Request (metadata) - Possible Wrong Password' , '<pre>%s</pre>' % traceback .format_exc ())
135
135
raise StopIteration
136
136
@@ -147,31 +147,31 @@ def application(environ, start_response):
147
147
#logging.info('request headers=%s', headers)
148
148
149
149
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 ' )])
151
151
yield message_html ('403 Wrong password' , 'Wrong password(%r)' % kwargs .get ('password' , '' ), 'GoAgent proxy.ini password is wrong!' )
152
152
raise StopIteration
153
153
154
154
netloc = urlparse .urlparse (url ).netloc
155
155
156
156
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 ' )])
158
158
yield message_html ('403 Hosts Deny' , 'Hosts Deny(%r)' % netloc , detail = 'url=%r' % url )
159
159
raise StopIteration
160
160
161
161
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 ' )])
163
163
yield message_html ('400 Bad Request' , 'length of URL too long(greater than %r)' % MAX_URL_LENGTH , detail = 'url=%r' % url )
164
164
raise StopIteration
165
165
166
166
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 ' )])
168
168
html = '' .join ('<a href="https://%s/">%s</a><br/>' % (x , x ) for x in ('google.com' , 'mail.google.com' ))
169
169
yield message_html ('GoAgent %s is Running' % __version__ , 'Now you can visit some websites' , html )
170
170
raise StopIteration
171
171
172
172
fetchmethod = getattr (urlfetch , method , None )
173
173
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 ' )])
175
175
yield message_html ('405 Method Not Allowed' , 'Method Not Allowed: %r' % method , detail = 'Method Not Allowed URL=%r' % url )
176
176
raise StopIteration
177
177
@@ -217,7 +217,7 @@ def application(environ, start_response):
217
217
if i == 0 and method == 'GET' :
218
218
deadline = URLFETCH_TIMEOUT * 2
219
219
else :
220
- start_response ('500 Internal Server Error ' , [('Content-Type' , 'text/html' )])
220
+ start_response ('200 OK ' , [('Content-Type' , 'text/html; charset=utf-8 ' )])
221
221
error_string = '<br />\n ' .join (errors )
222
222
if not error_string :
223
223
logurl = 'https://appengine.google.com/logs?&app_id=%s' % os .environ ['APPLICATION_ID' ]
0 commit comments