that puzzles me also.
fortunately, in the appengine ENV the Accept-Encoding was handled
transparently.
but in the development app box. the accept-encoding disabled, that's
not advantageous when developing.
as the temporary solution,i added a replace interface,that support the
accept-encodeing header, in myself lib when develop instead of
urlfetch :
looks like:

        import sys,os
        if (os.environ['SERVER_SOFTWARE']).find('Development') == -1: #in
the appengine box
                from google.appengine.api import urlfetch
        else:  # in the develop appserver
                from common import urlfetch
in urlfetch.py:



class Respon(object):
    content = None
    status_code = ""
    headers = {}
def fetch(url,headers ={'Accept-Encoding':'gzip'}):
    import urllib2, httplib
    import os,sys
    import StringIO
    sys.path.insert(0,os.environ['PROJECT_ROOT'])
    request = urllib2.Request('')
    respon = Respon()
    request = urllib2.Request(url)
    for k,v in headers.iteritems():
        request.add_header( k , v)
    opener = urllib2.build_opener()
    f = opener.open(request)
    data= f.read()
    if (f.headers.get('Content-Encoding','')).find('zip') == 1 :
#zipped
        import gzip,StringIO
        compressedstream = StringIO.StringIO(data)
        gzipper = gzip.GzipFile(fileobj=compressedstream)
        data = gzipper.read()
    respon.content = data
    respon.status_code = str(f.code)
    respon.headers = dict(f.headers)
    return respon


On Feb 10, 1:32 am, Tony Arkles <[email protected]> wrote:
> Hi,
>
> We're using urlfetch to access Yahoo Boss, which requires "Accept-
> Encoding: gzip" in the HTTP headers.
>
> The documentation doesn't indicate that this is a "forbidden" 
> header:http://code.google.com/appengine/docs/python/urlfetch/fetchfunction.html
>
> The code works great on the live server, but on the dev_appserver, the
> "Accept-Encoding" header is stripped out before the request is sent
> out.  From urlfetch_stub.py:
>
> _UNTRUSTED_REQUEST_HEADERS = frozenset([
>   'accept-encoding',
>   'content-length',
>   'host',
>   'referer',
>   'user-agent',
>   'vary',
>   'via',
>   'x-forwarded-for',
> ])
>
> Any idea why this is happening?  Is this by design, or is this a bug
> on the local appserver code?
>
> Cheers
> Tony

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to