问题描述
我回答以下问题:
not得到响应响应= httpclient.execute(请求);
请参阅我的回答there.Then我从我的回答评论
Peterdk
See my answer there.Then I got a comment on my answer from Peterdk
为:
的响应不是HTP presponse而是一个字符串。或者,你怎么得到它
是一个Htt的presponse?这是否取决于ResponseHandler所?
现在我有一个疑问,是的Htt presponse一个String?
Now i have a doubt "Is HttpResponse a String ?"
请帮我清楚我的这种怀疑和解释我什么是错在我的概念。
Please help me clear my this doubt and explain me what was wrong in my concept.
推荐答案
的你的答案的评论是毫无意义我的全部。我不知道为什么你下投了票,但实际上我不认为这个问题的措词不够好,在正确地回答你,但如果你怀疑真的有这样的事情,你可以通过检查逻辑思考过它该文档。的
简短的回答:
Htt的presponse不是一个字符串。
HttpResponse is not a String.
龙答:
的为 HttpClient.execute文档(串)
显示了该方法签名:
The documentation for HttpClient.execute(string)
shows this as the method signature:
public abstract HttpResponse execute (HttpUriRequest request)
所以很明显执行
返回一个的Htt presponse
。
现在>为的Htt presponse
你发现的Htt presponse
是一个接口,包括方法,如你在你的答案的方法: getStatusLine()
。你马上知道,接口没有一个字符串,所以的Htt presponse
不是字符串
,但如果你可能会认为这是另一种方式,也许字符串
工具的Htt presponse
,它应该是相当显然,字符串
没有所谓的一个方法 getStatusLine()
,它会是荒谬的东西作为一般作为字符串
来实现一个接口做HTTP。如果你的真正的要肯定,你可以查看再次看到字符串
没有 getStatusLine()
并没有实现接口的Htt presponse
。
Now if you go to the docs for HttpResponse
you find that HttpResponse
is an interface and includes methods such as the method you used in your answer: getStatusLine()
. Immediately you know that an interface isn't a String, so HttpResponse
isn't a String
, but in case you might think it's the other way and maybe String
implements HttpResponse
, it should be fairly obvious that String
doesn't have a method called getStatusLine()
and that it'd be ridiculous for something as generic as a String
to implement an interface to do with HTTP. If you really want to be sure, you can check the docs again and see that String
doesn't have getStatusLine()
and doesn't implement the interface HttpResponse
.
这篇关于是的Htt presponse字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!