Re: exceptions.AttributeError: "str" object has no attribute "group"

From: Eric <[email protected]>
Date: Wed, 16 Nov 2005 13:01:07 -0600

Also had to apply the following patch to icap_handler.py to fix this
bug in handling encapsulated requests...

139,141c139,147
< try:
< request.encap_reqs= encaps.group('req')
< except:

---
>                               if encaps:
>                                       try:
>                                               request.encap_reqs= encaps.group('req')
>                                       except:
>                                               request.encap_reqs = None
>                                       request.encap_res= encaps.group('res')
>                                       request.encap_body= encaps.group('body')
>                                       request.res_body =  ""
>                               else:
143,145c149,150
<                               request.encap_res= encaps.group('res')
<                               request.encap_body= encaps.group('body')
<                               request.res_body =  ""
---
>                                       request.encap_res = None
>                                       request.encap_body= None
root@duvel /usr/local/icap_server >diff -u icap_handler.py.orig icap_handler.py
--- icap_handler.py.orig        Sun Jul  7 20:21:46 2002
+++ icap_handler.py     Wed Nov 16 12:36:58 2005
@@ -136,13 +136,18 @@
                        elif request.command == 'respmod':
                                #print "DBG: respmod request is : ",request.header
                                encaps = get_header_match (ENCAPSULATED_respmod,request.header)
-                               try:
-                                       request.encap_reqs= encaps.group('req')
-                               except:
+                               if encaps:
+                                       try:
+                                               request.encap_reqs= encaps.group('req')
+                                       except:
+                                               request.encap_reqs = None
+                                       request.encap_res= encaps.group('res')
+                                       request.encap_body= encaps.group('body')
+                                       request.res_body =  ""
+                               else:
                                        request.encap_reqs = None
-                               request.encap_res= encaps.group('res')
-                               request.encap_body= encaps.group('body')
-                               request.res_body =  ""
+                                       request.encap_res = None
+                                       request.encap_body= None
                        else:
                                print "Currently ignoring command ",request.command
                        # Collect all the following data
On Sun, Oct 23, 2005 at 07:41:11PM -0500, Eric wrote:
> Great, I set up the python icap server and wrote a basically empty
> proxylet since it automatically updates Content-Length if you modify
> the body at all...guess it would work with any ICAP server.  Works great.
> 
> Thanks,
> eric.
Received on Wed Nov 16 2005 - 12:16:18 MST

This archive was generated by hypermail pre-2.1.9 : Thu Dec 01 2005 - 12:00:09 MST