"Can't parse headers" error in commcare-hq

Hi,

We are running our own instance of commcare-hq and often facing “Can’t
parse headers” error while loading the page and uploading case to server.
Any help to solve this issue is much appreciated.

Stake Trace:

File “/usr/lib/python2.6/site-packages/django/core/handlers/base.py”,
line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File “./submodules/core-hq-src/corehq/apps/hqwebapp/views.py”, line 128,
in login
return django_login(req, template_name=template_name,
authentication_form=EmailAuthenticationForm)
File “./submodules/auditcare-src/auditcare/decorators/login.py”, line
157, in decorated_login
response = func(request, *args, **kwargs)
File “/usr/lib/python2.6/site-packages/django/utils/decorators.py”, line
93, in _wrapped_view
response = view_func(request, *args, **kwargs)
File “/usr/lib/python2.6/site-packages/django/views/decorators/cache.py”,
line 79, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File “/usr/lib/python2.6/site-packages/django/contrib/auth/views.py”,
line 48, in login
auth_login(request, form.get_user())
File “/usr/lib/python2.6/site-packages/django/contrib/auth/init.py”,
line 85, in login
user_logged_in.send(sender=user.class, request=request, user=user)
File “/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py”,
line 172, in send
response = receiver(signal=self, sender=sender, **named)
File “/usr/lib/python2.6/site-packages/django/contrib/auth/models.py”,
line 51, in update_last_login
user.save()
File “/usr/lib/python2.6/site-packages/django/db/models/base.py”, line
460, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File “/usr/lib/python2.6/site-packages/django/db/models/base.py”, line
570, in save_base
created=(not record_exists), raw=raw, using=using)
File “/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py”,
line 172, in send
response = receiver(signal=self, sender=sender, **named)
File “./submodules/auditcare-src/auditcare/signals.py”, line 38, in
django_audit_save
AuditEvent.audit_django_save(sender, instance, instance_json, usr)
File “./submodules/auditcare-src/auditcare/models.py”, line 291, in
audit_django_save
cls._save_model_audit(audit, instance_id, instance_json, revision_id,
model_class.name, is_django=True)
File “./submodules/auditcare-src/auditcare/models.py”, line 242, in
_save_model_audit
prior_revs = db.view(‘auditcare/model_actions’, key=[‘model_types’,
model_class_name, instance_id]).all()
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line 971,
in all
return list(self.iterator())
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line 927,
in iterator
self._fetch_if_needed()
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line 1006,
in _fetch_if_needed
self.fetch()
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line 988,
in fetch
self._result_cache = self.view._exec(**self.params).json_body
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line 1076,
in _exec
return self._db.res.get(self.view_path, **params)
File “/usr/lib/python2.6/site-packages/restkit/resource.py”, line 114, in
get
params_dict=params_dict, **params)
File “/usr/lib/python2.6/site-packages/couchdbkit/resource.py”, line 111,
in request
payload=payload, headers=headers, **params)
File “/usr/lib/python2.6/site-packages/restkit/resource.py”, line 190, in
request
headers=self.make_headers(headers))
File “/usr/lib/python2.6/site-packages/restkit/client.py”, line 422, in
request
return self.perform(request)
File “/usr/lib/python2.6/site-packages/restkit/client.py”, line 363, in
perform
return self.get_response(request, conn)
File “/usr/lib/python2.6/site-packages/restkit/client.py”, line 459, in
get_response
location = p.headers().get(‘location’)
File “/usr/lib64/python2.6/site-packages/http_parser/http.py”, line 145,
in headers
self._check_headers_complete()
File “/usr/lib64/python2.6/site-packages/http_parser/http.py”, line 70,
in _check_headers_complete
raise NoMoreData(“Can’t parse headers”)

Regards,
Sathish

Hi Sathish,

I believe that updating your auditcare submodule reference to the
latest commit on master might solve this.

Cory

··· On Thu, Jul 26, 2012 at 3:51 AM, sathish wrote: > Hi, > > We are running our own instance of commcare-hq and often facing "Can't parse > headers" error while loading the page and uploading case to server. Any help > to solve this issue is much appreciated. > > Stake Trace: > > File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line > 111, in get_response > response = callback(request, *callback_args, **callback_kwargs) > File "./submodules/core-hq-src/corehq/apps/hqwebapp/views.py", line 128, > in login > return django_login(req, template_name=template_name, > authentication_form=EmailAuthenticationForm) > File "./submodules/auditcare-src/auditcare/decorators/login.py", line 157, > in decorated_login > response = func(request, *args, **kwargs) > File "/usr/lib/python2.6/site-packages/django/utils/decorators.py", line > 93, in _wrapped_view > response = view_func(request, *args, **kwargs) > File "/usr/lib/python2.6/site-packages/django/views/decorators/cache.py", > line 79, in _wrapped_view_func > response = view_func(request, *args, **kwargs) > File "/usr/lib/python2.6/site-packages/django/contrib/auth/views.py", line > 48, in login > auth_login(request, form.get_user()) > File "/usr/lib/python2.6/site-packages/django/contrib/auth/__init__.py", > line 85, in login > user_logged_in.send(sender=user.__class__, request=request, user=user) > File "/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py", > line 172, in send > response = receiver(signal=self, sender=sender, **named) > File "/usr/lib/python2.6/site-packages/django/contrib/auth/models.py", > line 51, in update_last_login > user.save() > File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line > 460, in save > self.save_base(using=using, force_insert=force_insert, > force_update=force_update) > File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line > 570, in save_base > created=(not record_exists), raw=raw, using=using) > File "/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py", > line 172, in send > response = receiver(signal=self, sender=sender, **named) > File "./submodules/auditcare-src/auditcare/signals.py", line 38, in > django_audit_save > AuditEvent.audit_django_save(sender, instance, instance_json, usr) > File "./submodules/auditcare-src/auditcare/models.py", line 291, in > audit_django_save > cls._save_model_audit(audit, instance_id, instance_json, revision_id, > model_class.__name__, is_django=True) > File "./submodules/auditcare-src/auditcare/models.py", line 242, in > _save_model_audit > prior_revs = db.view('auditcare/model_actions', key=['model_types', > model_class_name, instance_id]).all() > File "/usr/lib/python2.6/site-packages/couchdbkit/client.py", line 971, in > all > return list(self.iterator()) > File "/usr/lib/python2.6/site-packages/couchdbkit/client.py", line 927, in > iterator > self._fetch_if_needed() > File "/usr/lib/python2.6/site-packages/couchdbkit/client.py", line 1006, > in _fetch_if_needed > self.fetch() > File "/usr/lib/python2.6/site-packages/couchdbkit/client.py", line 988, in > fetch > self._result_cache = self.view._exec(**self.params).json_body > File "/usr/lib/python2.6/site-packages/couchdbkit/client.py", line 1076, > in _exec > return self._db.res.get(self.view_path, **params) > File "/usr/lib/python2.6/site-packages/restkit/resource.py", line 114, in > get > params_dict=params_dict, **params) > File "/usr/lib/python2.6/site-packages/couchdbkit/resource.py", line 111, > in request > payload=payload, headers=headers, **params) > File "/usr/lib/python2.6/site-packages/restkit/resource.py", line 190, in > request > headers=self.make_headers(headers)) > File "/usr/lib/python2.6/site-packages/restkit/client.py", line 422, in > request > return self.perform(request) > File "/usr/lib/python2.6/site-packages/restkit/client.py", line 363, in > perform > return self.get_response(request, conn) > File "/usr/lib/python2.6/site-packages/restkit/client.py", line 459, in > get_response > location = p.headers().get('location') > File "/usr/lib64/python2.6/site-packages/http_parser/http.py", line 145, > in headers > self._check_headers_complete() > File "/usr/lib64/python2.6/site-packages/http_parser/http.py", line 70, in > _check_headers_complete > raise NoMoreData("Can't parse headers") > > > Regards, > Sathish

Additionally, there’s a host of bug fixes in the latest python restkit
release which can cause symptoms like these. Updating to the latest release
of restkit, particularly after 4.1.5, will help.

··· On Thu, Jul 26, 2012 at 9:46 AM, Cory Zue wrote:

Hi Sathish,

I believe that updating your auditcare submodule reference to the
latest commit on master might solve this.

Cory

On Thu, Jul 26, 2012 at 3:51 AM, sathish tsathish@thoughtworks.com wrote:

Hi,

We are running our own instance of commcare-hq and often facing “Can’t
parse
headers” error while loading the page and uploading case to server. Any
help
to solve this issue is much appreciated.

Stake Trace:

File “/usr/lib/python2.6/site-packages/django/core/handlers/base.py”,
line
111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File “./submodules/core-hq-src/corehq/apps/hqwebapp/views.py”, line
128,
in login
return django_login(req, template_name=template_name,
authentication_form=EmailAuthenticationForm)
File “./submodules/auditcare-src/auditcare/decorators/login.py”, line
157,
in decorated_login
response = func(request, *args, **kwargs)
File “/usr/lib/python2.6/site-packages/django/utils/decorators.py”,
line
93, in _wrapped_view
response = view_func(request, *args, **kwargs)
File
"/usr/lib/python2.6/site-packages/django/views/decorators/cache.py",
line 79, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File “/usr/lib/python2.6/site-packages/django/contrib/auth/views.py”,
line
48, in login
auth_login(request, form.get_user())
File
"/usr/lib/python2.6/site-packages/django/contrib/auth/init.py",
line 85, in login
user_logged_in.send(sender=user.class, request=request,
user=user)
File “/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py”,
line 172, in send
response = receiver(signal=self, sender=sender, **named)
File “/usr/lib/python2.6/site-packages/django/contrib/auth/models.py”,
line 51, in update_last_login
user.save()
File “/usr/lib/python2.6/site-packages/django/db/models/base.py”, line
460, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
File “/usr/lib/python2.6/site-packages/django/db/models/base.py”, line
570, in save_base
created=(not record_exists), raw=raw, using=using)
File “/usr/lib/python2.6/site-packages/django/dispatch/dispatcher.py”,
line 172, in send
response = receiver(signal=self, sender=sender, **named)
File “./submodules/auditcare-src/auditcare/signals.py”, line 38, in
django_audit_save
AuditEvent.audit_django_save(sender, instance, instance_json, usr)
File “./submodules/auditcare-src/auditcare/models.py”, line 291, in
audit_django_save
cls._save_model_audit(audit, instance_id, instance_json, revision_id,
model_class.name, is_django=True)
File “./submodules/auditcare-src/auditcare/models.py”, line 242, in
_save_model_audit
prior_revs = db.view(‘auditcare/model_actions’, key=[‘model_types’,
model_class_name, instance_id]).all()
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line
971, in
all
return list(self.iterator())
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line
927, in
iterator
self._fetch_if_needed()
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line
1006,
in _fetch_if_needed
self.fetch()
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line
988, in
fetch
self._result_cache = self.view._exec(**self.params).json_body
File “/usr/lib/python2.6/site-packages/couchdbkit/client.py”, line
1076,
in _exec
return self._db.res.get(self.view_path, **params)
File “/usr/lib/python2.6/site-packages/restkit/resource.py”, line 114,
in
get
params_dict=params_dict, **params)
File “/usr/lib/python2.6/site-packages/couchdbkit/resource.py”, line
111,
in request
payload=payload, headers=headers, **params)
File “/usr/lib/python2.6/site-packages/restkit/resource.py”, line 190,
in
request
headers=self.make_headers(headers))
File “/usr/lib/python2.6/site-packages/restkit/client.py”, line 422, in
request
return self.perform(request)
File “/usr/lib/python2.6/site-packages/restkit/client.py”, line 363, in
perform
return self.get_response(request, conn)
File “/usr/lib/python2.6/site-packages/restkit/client.py”, line 459, in
get_response
location = p.headers().get(‘location’)
File “/usr/lib64/python2.6/site-packages/http_parser/http.py”, line
145,
in headers
self._check_headers_complete()
File “/usr/lib64/python2.6/site-packages/http_parser/http.py”, line
70, in
_check_headers_complete
raise NoMoreData(“Can’t parse headers”)

Regards,
Sathish