在CouchDB中设置显式响应Content-Type

nam*_*olk 5 json couchdb

我正在寻找一种方法来设置Contet-Typefor couchdb响应.

我有POST一个JSON使用Content-TypeAccept请求标题为application/json.但是当我调用GETfor该文档时,它会返回JSON响应Content-Type text/plain; charset=utf-8.我所期待的就是得到application/jsonContent-Type.

我怎样才能做到这一点?

POST

  • URL:http:// localhost:5984/hotel_staticdata
  • 请求机构: {"_id":"test-hotel-stat-data","content":[{"hotelcode": "AMB3_LON","hotelname": "Ambassadors Bloomsbury"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"},{"hotelcode": "ALE1_LON","hotelname": "Alexandra"}]}
  • 请求标题:接受:application/json Content-Type:application/json

得到

  • URL: http:// localhost:5984/hotel_staticdata/test-hotel-stat-data
  • 回应机构: {"_id":"test-hotel-stat-data","_rev":"3-6c6e26cd5690794886a8dc65308bf078","content":[{"hotelcode":"AMB3_LON","hotelname":"Ambassadors Bloomsbury"},{"hotelcode":"ALE1_LON","hotelname":"Alexandra"},{"hotelcode":"ALE1_LON","hotelname":"Alexandra"}]}
  • 响应标题:内容长度:249内容类型:text/plain; 字符集= utf-8的

而不是这个,我尝试PUT然后GET但结果是相同的.

  • CouchDB版本:1.6.1

nam*_*olk 5

我得到了答案.

当我使用Accept:application/json请求标头调用GET时.有用!该死的!我怎么想念它!

无论如何,如果您有任何不同的解决方案,请随时发布.