Modify

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6339 closed defect (fixed)

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

Reported by: Jay Xie Owned by: Jeff Hammel
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

     
    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 (0)

Change History (10)

comment:1 Changed 7 years ago by Jeff Hammel

Resolution: fixed
Status: newclosed

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

comment:2 Changed 7 years ago by Mario

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

comment:3 Changed 7 years ago by Ryan J Ollos

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

comment:4 in reply to:  2 ; Changed 7 years ago by Jay Xie

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

comment:5 in reply to:  3 ; Changed 7 years ago 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 :-)

comment:6 in reply to:  4 Changed 7 years ago 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 :-)

comment:7 in reply to:  1 Changed 7 years ago by Mario

Resolution: fixed
Status: closedreopened

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"

comment:8 in reply to:  5 Changed 7 years ago by Ryan J Ollos

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?

comment:9 Changed 7 years ago by Jeff Hammel

Resolution: fixed
Status: reopenedclosed

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

comment:11 Changed 7 years ago by Jeff Hammel

Resolution: fixed
Status: reopenedclosed

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jeff Hammel.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.