Я заметил, что org.apache.http.client.HttpClient
определяет метод execute
, который принимает целевой хост и параметр запроса.Как HttpClient выполняет дескриптор переопределенных путей?
/**
* Executes a request to the target using the default context.
*
* @param target the target host for the request.
* Implementations may accept <code>null</code>
* if they can still determine a route, for example
* to a default target or by inspecting the request.
* @param request the request to execute
*
* @return the response to the request. This is always a final response,
* never an intermediate response with an 1xx status code.
* Whether redirects or authentication challenges will be returned
* or handled automatically depends on the implementation and
* configuration of this client.
* @throws IOException in case of a problem or the connection was aborted
* @throws ClientProtocolException in case of an http protocol error
*/
HttpResponse execute(HttpHost target, HttpRequest request)
throws IOException, ClientProtocolException;
Я вникал в DefaultHttpClient
и DefaultRequestDirector
исходного кода, и стало очевидно, что проще execute(HttpRequest request)
метод разделяет запрос в объект HttpHost и объект HttpRequest и направляет вызов к более указанного метода (на самом деле , тот, который также принимает объект HttpContext
, - но в данный момент меня не интересует контекст).
Вопрос, так как запрос и хост могут принимать URI, как определяется окончательный URI? В чем они оба имеют абсолютный URI? Что, если они конфликтуют? Что они оба имеют частичные пути?
Спасибо oleg. Я надеялся, что это так, и с небольшим количеством копаний в связанных классах «Http ...», упомянутых в редактировании, я довольно уверен, что ваше описание всегда имеет место ... по крайней мере для класса DefaultHttpClient , –