Modify

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#6339 closed defect (fixed)

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

Reported by: xeroo Owned by: 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

     
    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 follow-up: Changed 5 years ago by k0s

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 follow-up: Changed 5 years ago 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

comment:3 follow-up: Changed 5 years ago by rjollos

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

comment:4 in reply to: ↑ 2 ; follow-up: Changed 5 years ago 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

comment:5 in reply to: ↑ 3 ; follow-up: Changed 5 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 5 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 5 years ago by mwehr

  • Resolution fixed deleted
  • Status changed from closed to reopened

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 5 years ago 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?

comment:9 Changed 5 years ago by k0s

  • Resolution set to fixed
  • Status changed from reopened to closed

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

comment:11 Changed 5 years ago by k0s

  • Resolution set to fixed
  • Status changed from reopened to closed

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

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from k0s. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.