本文整理匯總了Java中org.apache.commons.httpclient.HttpMethod.getResponseHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpMethod.getResponseHeaders方法的具體用法?Java HttpMethod.getResponseHeaders怎麽用?Java HttpMethod.getResponseHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.httpclient.HttpMethod
的用法示例。
在下文中一共展示了HttpMethod.getResponseHeaders方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doService
import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
private void doService(HttpMethod method, HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
outputRequestLog(req);
InputStream iStream = null;
ServletOutputStream oStream = null;
try {
long threadID = Thread.currentThread().getId();
log.debug("[" + threadID + "] forwarded to " + distributer.getRedirectUrl(req));
HttpClient client = new HttpClient();
log.debug("[" + threadID + "]send request.");
int resultCode = client.executeMethod(method);
log.debug("[" + threadID + "]got response: result code is " + resultCode);
res.setStatus(resultCode);
for (Header header : method.getResponseHeaders()) {
res.setHeader(header.getName(), header.getValue());
}
iStream = method.getResponseBodyAsStream();
oStream = res.getOutputStream();
writeOutputStream(iStream, oStream);
log.debug("[" + threadID + "] response sent to client.");
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new ServletException(e.getMessage(), e);
} finally {
if (iStream != null) {
iStream.close();
}
if (oStream != null) {
oStream.close();
}
}
}