Ticket #6339 (closed defect: fixed)

Opened 3 months ago

Last modified 2 months ago

"No Content-Length header set" error due to trac changeset 8609

Reported by: xeroo Assigned to: k0s
Priority: normal Component: AutocompleteUsersPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

Changeset 8609(http://trac.edgewall.org/changeset/8609) of trac trunk has modified req.write, where Content-Length must be set before req.write and unicode data is not accepted.

Here is my patch that works, but I'm not sure if it's the enough.

  • autocompleteusers/autocompleteusers.py

    old new  
    8282                                 user[NAME]) 
    8383                  for value, user in sorted(users) ] # value unused (placeholder need for sorting) 
    8484 
    85         req.write('\n'.join(users)) 
     85        req.send('\n'.join(users).encode('utf-8')) 
    8686 
    8787 
    8888    ### methods for ITemplateProvider 

Attachments

Change History

(follow-up: ↓ 7 ) 12/16/09 16:15:38 changed by k0s

  • status changed from new to closed.
  • resolution set to fixed.

(In [7270]) applied patch from #6339; closes #6339 , thanks for the patch and detective work!

(follow-up: ↓ 4 ) 12/16/09 17:02:24 changed by mwehr

Hi i think the Content-Length should also be set.
This patch applies to rev. 6288

===================================================================
--- D:/trac/my_trac/plugins/autocomplete user/autocompleteusers/autocompleteusers.py	(revision 94)
+++ D:/trac/my_trac/plugins/autocomplete user/autocompleteusers/autocompleteusers.py	(revision 95)
@@ -82,7 +82,10 @@
                                  user[NAME])
                   for value, user in sorted(users) ] # value unused (placeholder need for sorting)
 
-        req.write('\n'.join(users))
+        data = '\n'.join(users)
+        data = data.encode('utf-8')
+        req.send_header('Content-Length', len(data )) 
+        req.write(data)
 
 
     ### methods for ITemplateProvider

(follow-up: ↓ 5 ) 12/16/09 23:06:15 changed by rjollos

Does this mean that after applying this patch, you effectively have AutocompleteUsersPlugin working with 0.12?

(in reply to: ↑ 2 ; follow-up: ↓ 6 ) 12/17/09 01:57:09 changed by xeroo

Replying to mwehr:

Hi i think the Content-Length should also be set.
This patch applies to rev. 6288 {{{ =================================================================== --- D:/trac/my_trac/plugins/autocomplete user/autocompleteusers/autocompleteusers.py (revision 94) +++ D:/trac/my_trac/plugins/autocomplete user/autocompleteusers/autocompleteusers.py (revision 95) @@ -82,7 +82,10 @@ user[NAME]) for value, user in sorted(users) ] # value unused (placeholder need for sorting) - req.write('\n'.join(users)) + data = '\n'.join(users) + data = data.encode('utf-8') + req.send_header('Content-Length', len(data )) + req.write(data) ### methods for ITemplateProvider }}}

req.send will automatically set Content-Length and Content-Type, and there seems to be no other difference between req.send and req.write

(in reply to: ↑ 3 ; follow-up: ↓ 8 ) 12/17/09 08:36:40 changed by anonymous

Replying to rjollos:

Does this mean that after applying this patch, you effectively have AutocompleteUsersPlugin working with 0.12?

Hi,

yes its working, for me :-)

(in reply to: ↑ 4 ) 12/17/09 08:40:31 changed by anonymous

Replying to xeroo:

Replying to mwehr:

Hi i think the Content-Length should also be set.
This patch applies to rev. 6288 {{{ =================================================================== --- D:/trac/my_trac/plugins/autocomplete user/autocompleteusers/autocompleteusers.py (revision 94) +++ D:/trac/my_trac/plugins/autocomplete user/autocompleteusers/autocompleteusers.py (revision 95) @@ -82,7 +82,10 @@ user[NAME]) for value, user in sorted(users) ] # value unused (placeholder need for sorting) - req.write('\n'.join(users)) + data = '\n'.join(users) + data = data.encode('utf-8') + req.send_header('Content-Length', len(data )) + req.write(data) ### methods for ITemplateProvider }}}

req.send will automatically set Content-Length and Content-Type, and there seems to be no other difference between req.send and req.write

ahh ok i did not noticed that you use "req.send" , looks like this is a cleaner solution :-)

(in reply to: ↑ 1 ) 12/17/09 09:07:08 changed by mwehr

  • status changed from closed to reopened.
  • resolution deleted.

Replying to k0s:

(In [7270]) applied patch from #6339; closes #6339 , thanks for the patch and detective work!

Hi,

The fix from xeroo, includes also a change from "req.write" to "req.send"

(in reply to: ↑ 5 ) 12/18/09 02:10:15 changed by rjollos

Replying to anonymous:

yes its working, for me :-)

Thanks, that is very good to know. Should we add 0.12 to the list of tags on the wiki page for AutocompleteUsersPlugin?

(follow-up: ↓ 10 ) 12/19/09 10:34:52 changed by k0s

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [7270]) applied patch from #6339; closes #6339 , thanks for the patch and detective work!

(in reply to: ↑ 9 ) 12/21/09 20:00:38 changed by k0s

  • status changed from closed to reopened.
  • resolution deleted.

Replying to k0s:

(In [7270]) applied patch from #6339; closes #6339 , thanks for the patch and detective work!

Hmm, i actually have no idea how that got sent twice

12/21/09 20:03:03 changed by k0s

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [7293]) use req.send instead of req.write, closes #6339

01/20/10 07:55:12 changed by k0s

(In [7293]) use req.send instead of req.write, closes #6339


Add/Change #6339 ("No Content-Length header set" error due to trac changeset 8609)




Change Properties
Action