<div>Dear sudsers,</div><div><div><br></div><div>Someone created ticket 320 indicating that he could not use of either the patches included in ticket 311 or the full files attached to ticket 318 (and to the previous e-mail in this chain). I added a comment to ticket 320 but no response has been added, so.</div>
<div><br></div><div>Small summary of how to use the transport in 320:</div><div><ul><li>Download suds (I would suggest &quot;svn export <a href="http://svn.fedorahosted.org/svn/suds/trunk">http://svn.fedorahosted.org/svn/suds/trunk</a>&quot; better than checking out as indicated, to avoid pulling the svn control directories)</li>
<li>Download http.py and options.py from ticket 318</li><ul><li><a href="https://fedorahosted.org/suds/attachment/ticket/318/http.py">https://fedorahosted.org/suds/attachment/ticket/318/http.py</a></li><li><a href="https://fedorahosted.org/suds/attachment/ticket/318/options.py">https://fedorahosted.org/suds/attachment/ticket/318/options.py</a></li>
</ul><li>Replace suds/transport/http.py and suds/transport/options.py with the files just downloaded</li><li>Use suds as normal.</li></ul><div>Anyhow and to make the rewritten transport usable without having to tweak the suds installation, I am attaching a version that can be used from outside. The usage is as follows:</div>
<div><br></div></div><blockquote class="webkit-indent-blockquote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div><div>import DRoHttp</div><div><br></div><div>mytransport = DRoHttp.DRoHttpTransport</div><div>myclient = suds.client.Client(wsdlcontent, transport = mytransport)</div><div><br></div></div></blockquote>The transport works with the starndard transport options available in suds and because it is working outside of the suds structure, it does manually add the options that were mentioned in the previous e-mail:</div>
<div><div><ul><li>Option: &quot;compression&quot; added.</li></ul></div><blockquote style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div>A string that may be assigned the following values:</div><div><ul><li>yes: request compression and decompress incoming compressed content</li><li>no: do not request compression and do not decompress content even if present in the reply</li>
<li>auto: do not request compression but decompress if compression is present in the reply</li></ul><div>Default: &#39;yes&#39;</div></div></blockquote><div><ul><li>Option: compmethods</li></ul></div><blockquote style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div><div>A list of strings with the compression methods to be supported.</div><div><br></div><div>The supported methods: gzip, deflate, bzip2</div><div><br></div><div>Default: [&#39;gzip&#39;, &#39;deflate&#39;, &#39;bzip&#39;]</div>
</div></blockquote><br></div><div>An example disabling compression would be:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>import DRoHttp</div>
</div><div><div><br></div></div><div><div>mytransport = DRoHttp.DRoHttpTransport</div></div><div><div># Disable the transport compression for debugging purposes</div><div>myclient = suds.client.Client(wsdlcontent, transport = mytransport, compression = &#39;no&#39;)</div>
</div></blockquote><div><br></div><div>Or just testing the presence of bzip2 for example:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>
<div>import DRoHttp</div></div></div><div><div><div><br></div></div></div><div><div><div>mytransport = DRoHttp.DRoHttpTransport</div></div></div><div><div><div># Enable only bzip2 compression to test that</div></div></div>
<div><div><div>myclient = suds.client.Client(wsdlcontent, transport = mytransport, compmethods = [&#39;bzip2&#39;])</div></div></div></blockquote><div><br></div><div>Please let me know if there is any problem.</div><div><br>
</div><div>Best regards</div><div><br></div><div>Daniel<br><br><div class="gmail_quote">On Thu, May 6, 2010 at 23:51, Daniel Rodriguez <span dir="ltr">&lt;<a href="mailto:danjrod@gmail.com">danjrod@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Jeff,<div><br></div><div>As stated I have worked in the transport module as I said, as I believed there was room for improvement. Please find it attached for your consideration and for anyone else that may be willing to test it (the options.py and http.py can directly replace the existing files in suds/transport and be used straight away)</div>

<div><br></div><div>I have run a series of tests with compression enabled and disabled, tested sites with gzip and deflate (found none with bzip2) and wsdl in files or in urls. So far, everything worked and since they have many more changes than just the compression, I think they deserve their own ticket, for you to choose which one to accept (if any)</div>

<div><br></div><div>In options.py</div><div><ul><li>Variable: &quot;compression&quot; added.</li></ul></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>It may be assigned the following values:</div>

<div><ul><li>yes: request compression and decompress incoming compressed content</li><li>no: do not request compression and do not decompress content even if present in the reply</li><li>auto: do not request compression but decompress it if present in the reply</li>

</ul><div>Default: yes</div></div></blockquote><div><ul><li>Variable: compmethods</li></ul></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>A list with the compression methods to be supported.</div>

<div><br></div><div>So far: gzip, deflate, bzip2</div><div><br></div></div></blockquote><div>The changes in http.py are:</div><div><ul><li>open</li></ul></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

<div>The function is now urllib2 agnostic. It will try to detect if the passed url is a file, a url or data and act accordingly.</div><div><br></div><div>This allows passing a variable with the WSDL content inside, besides the current functionality (a url)</div>

<div><br></div><div>Still returning a &quot;file-like&quot; object</div></blockquote><ul><li>send</li></ul><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>The function is now urllib2 agnostic. It simply calls the appropriate function</div>

<div><br></div></blockquote>I think that both could be moved upward to __init__.py to the Transport class, given its library independence<div><br><div><ul><li>invoke (possibly a better name can be found)</li></ul></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

<div>New function that is called by open and send to perform http. This should be in the base class Transport and be redefined by new transports like this</div><div><br></div><div>This function is the one working with urllib2 directly or through the functions you had already provided</div>

<div><br></div><div>It may return a suds.transport.Reply or a file-like object for open</div><div><br></div><div>It does call two new functions that in my opinion could make it to the standard interface of Transport</div>

<div><ul><li>prerequest</li><li>postreply</li></ul>This should be called before sending the request to the network and before returning the reply to the caller.</div><div><br></div><div>I have used them to &quot;request&quot; compression and decompress if needed. Another example would be &quot;HttpAuthenticated&quot;, where you redefine open and send to add the credentials. This could go into &quot;prerequest&quot;</div>

</blockquote><ul><li>addcookies and getcookies</li></ul><blockquote style="margin:0 0 0 40px;border:none;padding:0px">I think the could be removed since they are one-liners</blockquote>
<ul><li>u2opener</li></ul><blockquote style="margin:0 0 0 40px;border:none;padding:0px">As stated in my comments in the code, I think there was a &quot;bug&quot; in the original code since self.urlopener was never being used and a new urlopener was being created for each and every call<br>

<br>Now a urlopener is created if needed or if the proxy options change during execution.<br><br>This could be improved by just checking if the proxy for a given scheme (http, https) has changed, but would require passing the url to this function</blockquote>

<ul><li>u2handlers</li></ul><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>Now a copy of self.options.proxy is made (if needed) to detect if they change during execution</div>
</div></blockquote><ul><li>prerequest and postreply as aforementioned</li></ul><div><br></div>Let me know what you think<div><br></div><div>Best regards</div><div><br></div><div><font color="#888888">Daniel</font><div><div>
</div><div class="h5"><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><div><br></div></div></blockquote><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div class="gmail_quote">On Thu, May 6, 2010 at 10:35, Daniel Rodriguez <span dir="ltr">&lt;<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jeff,<div><br></div><div>The following will let you test it.</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

<div><div>import suds</div><div>l_wsdl = &#39;<a href="http://webservices.daehosting.com/services/isbnservice.wso?WSDL" target="_blank">http://webservices.daehosting.com/services/isbnservice.wso?WSDL</a>&#39;</div>
<div>l_client = suds.client.Client(l_wsdl, gzip = False)</div><div><br></div><div>l_result = l_client.service.IsValidISBN10(&#39;0123456789&#39;)</div><div>print l_result</div><div><br></div><div># default behaviour is gzip = True as below</div>


<div>l_client2 = suds.client.Client(l_wsdl, gzip = True)</div><div><br></div><div>l_result = l_client2.service.IsValidISBN10(&#39;0123456789&#39;)</div><div>print l_result</div><div><br></div></div></blockquote><div><br>

</div>
<div>Anyhow, I think that the changes can be implemented also for Transport.open, so that if you have to download large WSDL files, the download will also happen compressed (if supported by the server)</div><div><br></div>


<div>I even think that the compression request and processing could be part of the Transport class, to let people implement transport with libraries that may not have native gzip support.</div><div><br></div><div>Since I have some free time in the next minutes, I will possibly add a new patch to the ticket, so you may decide which one you like more</div>


<div><br></div><div>Best regards</div><div><br></div><font color="#888888"><div>Daniel</div></font><div><div></div><div><div><br></div><div><div class="gmail_quote">On Wed, May 5, 2010 at 20:52, Jeff Ortel <span dir="ltr">&lt;<a href="mailto:jortel@redhat.com" target="_blank">jortel@redhat.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey Daniel,<br>
<br>
Thanks for the great suggestion, patch and for creating a ticket for this.  I&#39;ll review for inclusion in 0.4.  Can you recommend a public test site/service for this?<br>
<br>
Regards,<br><font color="#888888">
<br>
Jeff</font><div><br>
<br>
On 04/29/2010 07:53 AM, Daniel Rodriguez wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
Hello,<br>
<br>
I have added ticket 311 requesting this enhancement with attached<br>
patches for transport/http.py and transport/options.py<br>
<br>
Requesting compression can be turned off and on with the &quot;gzip&quot; option<br>
(a bool)<br>
<br>
The gzip decompression code works always. The reasoning behind this is:<br>
<br>
    * Some network providers may compress the data in HTTP responses in<br>
      order to decrease network traffic, expecting all clients to be<br>
      ready to decompress data<br>
<br>
Best regards<br>
<br>
Daniel<br>
<br>
On Sat, Apr 3, 2010 at 21:07, Daniel Rodriguez &lt;<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a><br></div><div>
&lt;mailto:<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a>&gt;&gt; wrote:<br>
<br>
    A &quot;break&quot; at the end of the &quot;if&quot; statement will not hurt and avoid<br>
    checking unnecessary headers.<br>
<br>
    Best regards<br>
<br>
<br>
    On Sat, Apr 3, 2010 at 02:14, Daniel Rodriguez &lt;<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a><br></div><div><div></div><div>
    &lt;mailto:<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a>&gt;&gt; wrote:<br>
<br>
        Hi Jeff et al,<br>
<br>
        If I am not wrong (I may have missed a configuration option),<br>
        suds is not using or requesting gzip compression.<br>
<br>
        I have added a few lines and tested at least requesting and<br>
        accepting gzip compression. My changes have been trivial and<br>
        this could be possibly added as an option to suds.<br>
<br>
        The changes I have made (against 3.9):<br>
<br>
        _File_: suds/transport/http.py:<br>
        _<br>
        _<br>
        _Extra imports_:<br>
<br>
        import gzip<br>
        import StringIO<br>
<br>
        _Class_: HttpTransport<br>
        _Method_: send<br>
<br>
        _Added:_<br>
<br>
        After:<br>
<br>
            * headers = request.headers<br>
<br>
        added the following line<br>
<br>
            * headers.update([(&#39;Accept-Encoding&#39;, &#39;gzip&#39;)])<br>
<br>
        _Changed:_<br>
<br>
            * result = Reply(200, fp.headers.dict, fp.read())<br>
<br>
        to<br>
<br>
            * replydata = fp.read()<br>
            * for header in fp.headers.dict.keys():<br>
            *       if header.lower() == &#39;content-encoding&#39; and<br>
              fp.headers.dict[header] == &#39;gzip&#39;:<br>
            *           replydatacompressedstream =<br>
              StringIO.StringIO(replydata)<br>
            *           gzipper =<br>
              gzip.GzipFile(fileobj=replydatacompressedstream)<br>
            *           replydata = gzipper.read()<br>
            * result = Reply(200, fp.headers.dict, replydata)<br>
<br>
        Best regards<br>
<br>
        Daniel<br>
<br>
<br>
<br>
<br>
<br></div></div><div>
_______________________________________________<br>
suds mailing list<br>
<a href="mailto:suds@lists.fedoraproject.org" target="_blank">suds@lists.fedoraproject.org</a><br>
<a href="https://admin.fedoraproject.org/mailman/listinfo/suds" target="_blank">https://admin.fedoraproject.org/mailman/listinfo/suds</a><br>
</div></blockquote>
<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></blockquote></div></div><div><div></div><div class="h5"><div><div><br></div><div><br><br><div class="gmail_quote">On Thu, May 6, 2010 at 10:35, Daniel Rodriguez <span dir="ltr">&lt;<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jeff,<div><br></div><div>The following will let you test it.</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px">

<div><div>import suds</div><div>l_wsdl = &#39;<a href="http://webservices.daehosting.com/services/isbnservice.wso?WSDL" target="_blank">http://webservices.daehosting.com/services/isbnservice.wso?WSDL</a>&#39;</div>
<div>l_client = suds.client.Client(l_wsdl, gzip = False)</div><div><br></div><div>l_result = l_client.service.IsValidISBN10(&#39;0123456789&#39;)</div><div>print l_result</div><div><br></div><div># default behaviour is gzip = True as below</div>


<div>l_client2 = suds.client.Client(l_wsdl, gzip = True)</div><div><br></div><div>l_result = l_client2.service.IsValidISBN10(&#39;0123456789&#39;)</div><div>print l_result</div><div><br></div></div></blockquote><div><br>

</div>
<div>Anyhow, I think that the changes can be implemented also for Transport.open, so that if you have to download large WSDL files, the download will also happen compressed (if supported by the server)</div><div><br></div>


<div>I even think that the compression request and processing could be part of the Transport class, to let people implement transport with libraries that may not have native gzip support.</div><div><br></div><div>Since I have some free time in the next minutes, I will possibly add a new patch to the ticket, so you may decide which one you like more</div>


<div><br></div><div>Best regards</div><div><br></div><font color="#888888"><div>Daniel</div></font><div><div></div><div><div><br></div><div><div class="gmail_quote">On Wed, May 5, 2010 at 20:52, Jeff Ortel <span dir="ltr">&lt;<a href="mailto:jortel@redhat.com" target="_blank">jortel@redhat.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey Daniel,<br>
<br>
Thanks for the great suggestion, patch and for creating a ticket for this.  I&#39;ll review for inclusion in 0.4.  Can you recommend a public test site/service for this?<br>
<br>
Regards,<br><font color="#888888">
<br>
Jeff</font><div><br>
<br>
On 04/29/2010 07:53 AM, Daniel Rodriguez wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
Hello,<br>
<br>
I have added ticket 311 requesting this enhancement with attached<br>
patches for transport/http.py and transport/options.py<br>
<br>
Requesting compression can be turned off and on with the &quot;gzip&quot; option<br>
(a bool)<br>
<br>
The gzip decompression code works always. The reasoning behind this is:<br>
<br>
    * Some network providers may compress the data in HTTP responses in<br>
      order to decrease network traffic, expecting all clients to be<br>
      ready to decompress data<br>
<br>
Best regards<br>
<br>
Daniel<br>
<br>
On Sat, Apr 3, 2010 at 21:07, Daniel Rodriguez &lt;<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a><br></div><div>
&lt;mailto:<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a>&gt;&gt; wrote:<br>
<br>
    A &quot;break&quot; at the end of the &quot;if&quot; statement will not hurt and avoid<br>
    checking unnecessary headers.<br>
<br>
    Best regards<br>
<br>
<br>
    On Sat, Apr 3, 2010 at 02:14, Daniel Rodriguez &lt;<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a><br></div><div><div></div><div>
    &lt;mailto:<a href="mailto:danjrod@gmail.com" target="_blank">danjrod@gmail.com</a>&gt;&gt; wrote:<br>
<br>
        Hi Jeff et al,<br>
<br>
        If I am not wrong (I may have missed a configuration option),<br>
        suds is not using or requesting gzip compression.<br>
<br>
        I have added a few lines and tested at least requesting and<br>
        accepting gzip compression. My changes have been trivial and<br>
        this could be possibly added as an option to suds.<br>
<br>
        The changes I have made (against 3.9):<br>
<br>
        _File_: suds/transport/http.py:<br>
        _<br>
        _<br>
        _Extra imports_:<br>
<br>
        import gzip<br>
        import StringIO<br>
<br>
        _Class_: HttpTransport<br>
        _Method_: send<br>
<br>
        _Added:_<br>
<br>
        After:<br>
<br>
            * headers = request.headers<br>
<br>
        added the following line<br>
<br>
            * headers.update([(&#39;Accept-Encoding&#39;, &#39;gzip&#39;)])<br>
<br>
        _Changed:_<br>
<br>
            * result = Reply(200, fp.headers.dict, fp.read())<br>
<br>
        to<br>
<br>
            * replydata = fp.read()<br>
            * for header in fp.headers.dict.keys():<br>
            *       if header.lower() == &#39;content-encoding&#39; and<br>
              fp.headers.dict[header] == &#39;gzip&#39;:<br>
            *           replydatacompressedstream =<br>
              StringIO.StringIO(replydata)<br>
            *           gzipper =<br>
              gzip.GzipFile(fileobj=replydatacompressedstream)<br>
            *           replydata = gzipper.read()<br>
            * result = Reply(200, fp.headers.dict, replydata)<br>
<br>
        Best regards<br>
<br>
        Daniel<br>
<br>
<br>
<br>
<br>
<br></div></div><div>
_______________________________________________<br>
suds mailing list<br>
<a href="mailto:suds@lists.fedoraproject.org" target="_blank">suds@lists.fedoraproject.org</a><br>
<a href="https://admin.fedoraproject.org/mailman/listinfo/suds" target="_blank">https://admin.fedoraproject.org/mailman/listinfo/suds</a><br>
</div></blockquote>
<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div></div></div></div>
</blockquote></div><br></div>