I'm not sure why you'd want to do this, except maybe to hide the fact that 
your site does not have a valid SSL certificate. One cause of latency is 
the fact that you're buffering the entire response in App Engine before 
sending it along to the client, but really what you're doing is a hack and 
not good practice. You can get a real cert for free at 
https://letsencrypt.org and save yourself the trouble. 

On Thursday, March 23, 2017 at 9:13:50 AM UTC-4, bruce lee wrote:
>
> I use GAE platform to forward HTTP SSL data.(python webapp2)
> why?use ssl client make large time_wait connect?
> But HTTP is normal.
>
>
>
>
> code:
>
>
> #!/usr/bin/env python
> #
> # Copyright 2007 Google Inc.
> #
> # Licensed under the Apache License, Version 2.0 (the "License");
> # you may not use this file except in compliance with the License.
> # You may obtain a copy of the License at
> #
> #     http://www.apache.org/licenses/LICENSE-2.0
> #
> # Unless required by applicable law or agreed to in writing, software
> # distributed under the License is distributed on an "AS IS" BASIS,
> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> # See the License for the specific language governing permissions and
> # limitations under the License.
> #
>
> import base64, logging
> import webapp2
> from google.appengine.api import urlfetch
>
> class MainHandler(webapp2.RequestHandler):
>     def get(self):
>         useSSL = 0
>         _url = self.request.url.lower()
>         if _url.find('https://')==0:
>             useSSL = 1
>
>         _url = self.request.url #restore
>         
>         _path = self.request.path
>         
>         if _path=="/": #for test
>             self.response.headers["Content-Type"] = "text/html; 
> charset=utf-8"
>             self.response.write("Hello, guys")
>         else:      
>             nPos = _url.find(_path)    
>             sub_url = _url[nPos:len(_url)]
>
>             if useSSL==1:
>                 url = "https://198.52.119.103:443"+sub_url
>             else:
>                 url = "http://198.52.119.103"+sub_url
>
>             rpc = urlfetch.create_rpc()
>             urlfetch.make_fetch_call(rpc, url, validate_certificate=False)
>
>
>             # ... do other things ..
>             try:
>                 result = rpc.get_result()
>                 if result.status_code == 200:
>                     text = result.content
>                     self.response.write(text)
>                 else:
>                     self.response.status_int = result.status_code
>                     self.response.write('URL returned status code 
> {}'.format(result.status_code))
>             except urlfetch.DownloadError:
>                 self.response.status = 500
>                 self.response.write('Error fetching URL')
>
>     def post(self):
>         useSSL = 0
>         _url = self.request.url.lower()
>         if _url.find('https://')==0:
>             useSSL = 1
>
>         _url = self.request.url #restore
>         
>         _path = self.request.path
>         
>         if _path=="/": #for test
>             self.response.headers["Content-Type"] = "text/html; 
> charset=utf-8"
>             self.response.write("Hello, guys")
>         else:      
>             nPos = _url.find(_path)    
>             sub_url = _url[nPos:len(_url)]
>     
>
>             if useSSL==1:
>                 url = "https://test.server.com:443"+sub_url
>             else:
>                 url = "http://test.server.com"+sub_url
>
>             
>                 #def make_fetch_call(rpc, url, payload=None, method=GET, 
> headers={},
>                 #    allow_truncated=False, follow_redirects=True,
>                 #    validate_certificate=None):
>
>             _headers = {'Content-Type': 'application/octet-stream', 
> 'Content-Length': self.request.headers['Content-Length']}
>             rpc = urlfetch.create_rpc()
>             urlfetch.make_fetch_call(rpc, url, self.request.body, 2, 
> _headers, validate_certificate=False)
>
>
>             # ... do other things ..
>             try:
>                 result = rpc.get_result()
>                 if result.status_code == 200:
>                     text = result.content
>                     self.response.write(text)
>                 else:
>                     self.response.status_int = result.status_code
>                     self.response.write('URL returned status code 
> {}'.format(result.status_code))
>             except urlfetch.DownloadError:
>                 self.response.status = 500
>                 self.response.write('Error fetching URL')
>       
> app = webapp2.WSGIApplication([
>     ('.*', MainHandler)
> ], debug=True)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/4a1005f7-02d1-48bf-84db-f488ad918921%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to