문제

I am trying to build a web service system between 2 back-end written in django. However, even after changing the HttpResponse to json type:

HttpResponse('{"operation":"done"}',mimetype='application/json')

I still get the http header information in the other django machine:

{u'body': u'{"myjson":"here"}', u'headers': {'status': 200, 'content-length': '235', 'server': 'Google Frontend', 'cache-control': 'private, x-gzip-ok=""', 'date': 'Thu, 05 May 2011 06:16:16 GMT', 'content-type': 'application/json'}}

The header information is simply not necessary for me. Is there any convenient way to strip it?

[Edited] The lib I use to conduct restFUL request is: http://code.google.com/p/python-rest-client/wiki/Using_Connection

Thanks

도움이 되었습니까?

해결책

I finally discovered that returned response is a collection type:

def getSOAResponse(soa, uri, parameters):
    conn = Connection(soa)
    value = conn.request_get(uri, args=parameters)
    return value

If you take the response with the function above, the value you get here is actually a map.

Then you are able to access the body part of the response simply with:

body = value['body']

Problem solved. The header part of the response is no longer an issue.

[Edited] Silly me. It's just specified in the doc: http://code.google.com/p/python-rest-client/wiki/Using_Connection

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top