1
我已經啓用日誌記錄輸出爲Apache HTTP客戶端庫,這是一個示例應答的服務器可以響應一個我的帖子:什麼可能是JSON響應被分成多行的原因?
D/org.apache.http.wire(18597): << "HTTP/1.1 200 OK[EOL]"
D/org.apache.http.wire(18597): << "X-Backside-Transport: OK OK,OK OK,OK OK[EOL]"
D/org.apache.http.wire(18597): << "Date: 2013-05-07T16:19:49+03:00[EOL]"
D/org.apache.http.wire(18597): << "Content-Type: application/json[EOL]"
D/org.apache.http.wire(18597): << "User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)[EOL]"
D/org.apache.http.wire(18597): << "Surrogate-Capability: cache-b2="Surrogate/1.0"[EOL]"
D/org.apache.http.wire(18597): << "Cache-Control: max-age=259200[EOL]"
D/org.apache.http.wire(18597): << "X-Cache: MISS from cache-b2[EOL]"
D/org.apache.http.wire(18597): << "Transfer-Encoding: chunked[EOL]"
D/org.apache.http.wire(18597): << "Via: 1.1 cache-b2 (squid)[EOL]"
D/org.apache.http.wire(18597): << "Connection: keep-alive[EOL]"
D/org.apache.http.wire(18597): << "12A[EOL]"
D/org.apache.http.wire(18597): << "{"lightLoginResponse":{"authenticationToken":{"token":{"$":"b17SI\/E0exjXPbsYgSusIVr7I0MMxLsVxrw6rXgOzpoGKwdVN+isYJTOW2ZP\/r3Bm9x+zP9xxCSEQ58R8Cm4GKRPjhrUwBbaibD8un5aPIKWk8k74+0vIMApnNo5DODyEuVBNvvmoSJ66ri7iF7iBx98BbyiGNswkfXP1tG4RXrDHuUmmrSwZltAIoBTfDxV05R61vxZg8JbNfPyfj7bwpvaVHaA8UUGKRrk03yim9jG"
D/org.apache.http.wire(18597): << "[\r]"
D/org.apache.http.wire(18597): << "[\n]"
D/org.apache.http.wire(18597): << "5A8[EOL]"
D/org.apache.http.wire(18597): << "Fg+9GaCUgOkbTB0SPStdwW8UhFctS\/5vK1fGqcLBdHO3\/bzLIWIIx1kenoydi5v\/h7xc7EAxTfXyy\/jUxeKgG2XgNCJqwsZ6Pp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Lk\/FO7EBQ4ug7WtS3MlylvvHXorv+IN1++xAj3sduJIWmKObBtA76jDUiTvgCJ2mp4VLI5me9UsIxRnFJheixLmU3vZdqRWJIh6WSwJ15r+dV34aGB2WzKQtrSc5LO5SI3C7fJqgRuZfFHQTdtldJz8+D4gelbkIlTQrQknY46qJrAQFRvbyE\/ndRnun0ho76KM5CL965G0Pdy5YPG\/PfwE5\/CaWWYxg303rJMC3HNNqSqIq6Qmi4Vhm8870Yr5BzUTudcZbhx"
D/org.apache.http.wire(18597): << "[\r]"
D/org.apache.http.wire(18597): << "[\n]"
D/org.apache.http.wire(18597): << "5A8[EOL]"
D/org.apache.http.wire(18597): << "RBKnEF5hKSVH+YNLUwVpUzokS+kQKVN\/F+mr72gXlVFKuDeAY5kyAcDslOKCJmYn35c7TJP+iF4SvjYs2qLc8nXGo0p5N5INhtf9NMtYAhzWTD8nnecvg0B3v5WU2Ped+mQOC9mMTOeuzwFfZrX0WROBqM9M68Qu+fI29wAhQ\/8j7FYhisBaZCl4x09uH7fn+xWFQ9JLhxBdZcA82bzydXB3fVbhLi8QwwkQ5OuWhtg6vN3bry\/G\/nIcnjRQxoCvK6kMaVgaAXLF6MGmPP7e7Xgcsml8yPHjGVmp5sIOUVQZVH4eifncfgYzr7a\/naFbnTAhJK2I5XnV6KIJhngJzM54Vf1q3uZt9FxFFDGBK6X3iw9kNTfoOA161Ia72TnTu3enu0OMX7fzuJ9nissjhmFxfbwS5bkurdM4eW8OUJyEi03sNSdODw4h0O2TqrD6QfeKOlM+oK1Vx3FWPdQ7eYZaNCgeyYH7UM+k3vgChVUmbciTare6tyxC1DZAgMMuNMRTN4mVTRxJRrTt7vuUUdOkexzW07oOXmaH\/lRTvwX6+Pmp44LEVeOCkKYRm6fJUidO99WFk41zQrH9OjxNdoe512NrrtkLm6gVKidLRZC+8l1N88b6Dle\/g2kZCasQmv8\/whdk\/6QLwBVSypTZEhucVcuvNEZztMhlZhXO1Pz0mewESm8wIKBqbTgbJmnxYzPw7zy+3qzuyXLojTDqlnfLKtsIt8y3J+q33aYRa5ysr43kw4TUEmOcKL3sgLpy1H0H0ruchBBFn\/trEeVxlhbikr0ntb9ZRkhuw07wTdLCAXkQR\/Dxef1tRJRH\/6VvlCwtPceCUvVer36eoQg10Rp+Ve\/936kLtDGnfTU+WAboSRLCd\/0AlkPN49DdMM0afRR+BNie0oIiF1zirfHTQeF1iD+ukVXLHuj2nGWuy7zSr0VCVVan+zjhm\/btzIJl3clunO9T2hq2gOyGmwmpg4nvkat5aGdGApZjwnJtqex3aW+qNQNgTOaVd4z42OHBepGirFGu3v5V6aXctJdQIU7Zmx
3JbUxpGe9yHW3Io0vczdvznxH\/dZIarTepvIBfuwUztVYlpfW\/Lvdm29YkGrPeKb4DKkdAA1dmBVz4Pcat+auhqV0oajt4MIIRZnX41XtQQoIX6+19ITA5CboOYZaXhkU8bmbiEYbodXEqVELVzqRpyzqN2ogx4qmk4YZ1Vw0Q9csDu8ocA2MzJSyUGpnOPkviuHP2h4Z7+AqnF9MUuHvQFkWDY58gPVsswK2QsE\/eRM\/sQbV3n7pIIBRwNzUAOhsoLPSGJfXqyATNlSh8WBC4QYJamFIolNfcKfHIg5yL1WeCKhLwMWqQENFQ3pN\/UguVkYpv4lCrmw2wKl8fgTeqMfm1uAXT0YGowel\/Em3zMyX05mUbKt4tsQy"
D/org.apache.http.wire(18597): << "[\r]"
D/org.apache.http.wire(18597): << "[\n]"
D/org.apache.http.wire(18597): << "264[EOL]"
D/org.apache.http.wire(18597): << "AptjdnYveZUSeMVszlcctrEKrKWw4DBQgtr5Bf5u\/9gzwFircV0JxNEbXRUKXxGDnPYg0mJVufhHl6\/qwt\/hQ6koUHFBHs2+p\/P+tlzoq9vP5s5gELupgBLzmioPqwgCsk8CeML6mwz2EMTXQcmN2XYRMlTYBSiRFVsq2wfHOiNh\/pCBV5u9iAqfURfWhCVS4sBzlP72ko9vlnGfcFFfQRzl5r\/bBcUW9qw96LfF9VDoJp2hyT\/JQCD0h4gf\/hAC+ol58DrlAWGe++nymQIaxt\/FDLNTS2pxQ8p7Bkstd9FrOXBitelbynxQLY+9KcEVOmxhhGdh4aGle3P8eyrXYQnaAM7KtHI4lkw5+mhQPxoc2AkjwpczXy"},"authLevel":{"$":1},"loginTime":{"$":"2013-05-07T13:19:52.415Z"},"notAfter":{"$":"2013-05-07T13:29:03Z"},"sessionMaxLength":{"$":1800},"tokenMaxAge":{"$":551},"profileId":{"$":"c1Osiab8eGmtYIog3vxda0OZu"
D/org.apache.http.wire(18597): << "3POjgr+Gx4iNNgxaLk="}}}}"
D/org.apache.http.wire(18597): << "[\r]"
D/org.apache.http.wire(18597): << "[\n]"
如果你看一下身體,你會看到, JSON響應被分成多行。我之前沒有遇到過這個問題,並且想知道是否有任何理由將其分成多行。讀取12A[EOL]
,264[EOL]
和5A8[EOL]
的行是十六進制值,似乎表示以下行的長度。
如果這實際上只是一個自定義的實現,原因不明(或者可能只是安全性),那麼最好的方法是去掉無用的行並獲得響應的有效JSONObject
。
對不起,如果這個話題是離題。謝謝。