#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
82 82 user[NAME]) 83 83 for value, user in sorted(users) ] # value unused (placeholder need for sorting) 84 84 85 req. write('\n'.join(users))85 req.send('\n'.join(users).encode('utf-8')) 86 86 87 87 88 88 ### methods for ITemplateProvider
Attachments (0)
Change History (10)
comment:1 follow-up: 7 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 follow-up: 4 Changed 15 years ago by
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: 5 Changed 15 years ago by
Does this mean that after applying this patch, you effectively have AutocompleteUsersPlugin working with 0.12?
comment:4 follow-up: 6 Changed 15 years ago by
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 follow-up: 8 Changed 15 years ago by
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 Changed 15 years ago by
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 ITemplateProviderreq.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 Changed 15 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:8 Changed 15 years ago by
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 15 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
comment:11 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
(In [7270]) applied patch from #6339; closes #6339 , thanks for the patch and detective work!