That is due to Request.end_headers() called twice. Please report it to
the plugin maintainers.

On Wed, Mar 4, 2020 at 2:42 PM Velu Narasimman <[email protected]> wrote:
>
> Hi team,
>
>     I am facing this "headers have already been sent" error in an AJAX call. 
> I am not able to fix it. I need your hellp. Would be better if someone could 
> explain this issue.
>
> 2020-03-04 11:00:45,582 Trac[main] ERROR: [172.24.188.116] Internal Server 
> Error: <RequestWithSession "POST '/admin/pros users/users'">, referrer 
> 'https://prism30.aspiresys.com/Merlin/admin/pros%20users/users'
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.7/dist-packages/Trac-1.0.15-py2.7.egg/trac/web/main.py",
>  line 631, in _dispatch_request
>     dispatcher.dispatch(req)
>   File 
> "/usr/local/lib/python2.7/dist-packages/Trac-1.0.15-py2.7.egg/trac/web/main.py",
>  line 325, in dispatch
>     req.send(output, content_type or 'text/html')
>   File 
> "/usr/local/lib/python2.7/dist-packages/Trac-1.0.15-py2.7.egg/trac/web/api.py",
>  line 556, in send
>     self.end_headers()
>   File 
> "/usr/local/lib/python2.7/dist-packages/Trac-1.0.15-py2.7.egg/trac/web/api.py",
>  line 476, in end_headers
>     self._write = self._start_response(self._status, self._outheaders)
> RuntimeError: headers have already been sent
>
> Above chunk is the error. And below is how I write my json response to the 
> AJAX call.
>     def respond(self, req, data, code=200):
>         """Respond to the JSON request by sending the JSON-encoded data 
> back."""
>         json_data = json.dumps(data)
>         req.send_response(code)
>         req.send_header('Content-Type', 'application/json')
>         req.send_header('Content-Length', len(json_data))
>         req.write(json_data)
>         raise RequestDone
>
> Not sure if I am missing any code here in this respond method. Welcome your 
> suggestions to fix this error.




-- 
Jun Omae <[email protected]> (大前 潤)

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/trac-users/CAEVLMaiprmuevwr6AkzqPf%2BSNRXW-YVL2HCx_00HGPg9vMBhCg%40mail.gmail.com.

Reply via email to