Hi Bill,

I'll ask the Python library owner to follow up with you.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

On Nov 22, 12:42 pm, "Bill, KE1G" <ke1g...@gmail.com> wrote:
> This turns out to be largely due to the current ZSI (version 2.0rc3)
> using "Content-length" as the header field name, whereas the
> adwords python library's common.zsi.HttpsConnectionHandler
> wrapper code (wrapps httplib for ZSI) presumes that it will use
> "Content-Length" (which I assume that it did in an older version
> of ZSI, so this code will have worked for others).
>
> This assumption occurs in both the send and the putheader
> method.  The code works when I patch putheader to:
>
> 1. Check header.lower() against 'content-length' to decide to
> skip it.  (I also just call the super class method rather than
> re-implementing the header formatting.)
>
> and patch send to:
>
> 2. Check for a state(*) of _CS_REQ_SENT as a sign that we are
> recursing from the call to httplib.HTTPSConnection.endheaders()
> further down in the function, rather than try to recognize that the
> text looks like a header.
>
> 3. To call the superclass putheader to add its own content-length
> header (since the new implementation in the sub-class, as
> detailed above would just discard it now, no matter the capitolization
> variations), passing str() of the length of the compressed data, since
> the super class doesn't do well with integers.
>
> I can supply my patched and commented code if someone, or a
> library maintainer, needs it.
>
> Bill
>
> (*) Note that attributes beginning with, but not ending with, double
> underscore get "name mangled" by having an underscore and
> the class name prefixed to them.  Thus to access the __state
> attribute one really needs to use:
>   self._HTTPConnection__state
> in methods of the subclass, since self.__state there gets mangled to
>   self.HttpsConnectionHandler__state
> Note that this does not bode well for the use of self.__state in the
> getresponse() method accomplishing what you think it does.
>
> Double underscore attributes are much more strongly private than
> single underscore attributes.  The implication is really that these
> are
> private even from subclasses.  Thus it might be better, in send, to
> add a "__we_are_gzipping" attribute before the call to endheaders,
> and use hasattr to check for it in the "lets not gzip again" test.

-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
http://adwordsapi.blogspot.com
http://groups.google.com/group/adwords-api
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en

Reply via email to