• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StatusLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.commons.httpclient.StatusLine的典型用法代码示例。如果您正苦于以下问题:Java StatusLine类的具体用法?Java StatusLine怎么用?Java StatusLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StatusLine类属于org.apache.commons.httpclient包,在下文中一共展示了StatusLine类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readResponse

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
public SimpleResponse readResponse() throws IOException {
    try {
        String line = null;
        do {
            line = HttpParser.readLine(in, HTTP_ELEMENT_CHARSET);
        } while (line != null && line.length() == 0);

        if (line == null) {
            setKeepAlive(false);
            return null;
        }
        SimpleResponse response = new SimpleResponse(
                new StatusLine(line),
                HttpParser.parseHeaders(this.in, HTTP_ELEMENT_CHARSET),
                this.in);
        return response;
    } catch (IOException e) {
        close();
        throw e;
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:22,代码来源:SimpleHttpServerConnection.java


示例2: verifyUri

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
/**
 * This method tries to establish HTTP connection for passed URI
 * @param uri The URI to verify
 * @param responseLineList 
 *        This list collects response lines for broken URIs
 * @param brokenUriList
 *        This list collects broken URIs
 */
private void verifyUri(String uri, List<String> responseLineList, List<String> brokenUriList) {
	HttpClient client = new HttpClient();
	client.getHttpConnectionManager().getParams().
	setConnectionTimeout(10000);
	try {
		HttpMethod method = new GetMethod(uri);
		method.setFollowRedirects(true);
		client.executeMethod(method);
		int response = method.getStatusCode();
		if (response != 200) {
			StatusLine responseLine = method.getStatusLine();
			log.info("uri: " + uri + ", response: " + response + ", responseLine: " + responseLine.toString());
			brokenUriList.add(uri);
			responseLineList.add(responseLine.toString());
		}
		method.releaseConnection();
	} catch (IOException e) {
		log.info("Unable to connect to �" + uri + "� verification error: " + e);
		brokenUriList.add(uri);
		responseLineList.add(e.getMessage());
	} 
}
 
开发者ID:ait-ngcms,项目名称:ffma,代码行数:31,代码来源:PreservationRiskmanagementServiceImpl.java


示例3: parse

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
public static HttpHeader parse(InputStream in, String targetUrl) throws IOException {
    String line = LaxHttpParser.readLine(in, "ISO-8859-1");
    if (line == null || !StatusLine.startsWithHTTP(line)) {
        return null;
    }
    HttpHeader result = new HttpHeader();
    result.status = parseStatusLine(line);
    for (Header header : LaxHttpParser.parseHeaders(in, ARCConstants.DEFAULT_ENCODING)) {
        switch (header.getName().toLowerCase()) {
            case "location":
                try {
                    result.rawLocation = header.getValue();
                    URL url = new URL(targetUrl);
                    result.location = new URL(url, header.getValue()).toString().replace(" ", "%20");
                } catch (MalformedURLException e) {
                    // skip it
                }
                break;
            case "content-type":
                result.contentType = header.getValue();
                break;
        }
    }
    return result;
}
 
开发者ID:nla,项目名称:bamboo,代码行数:26,代码来源:HttpHeader.java


示例4: checkStatusCode

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
protected void checkStatusCode(ProxyContext context)
{
    int statusCode = context.getStatusCode();
    // FIXME: Why do this only for HTTP Proxy? Why not WebServices?
    if (statusCode >= 400 && statusCode != 401 & statusCode != 403 && !context.isSoapRequest())
    {
        StatusLine statusLine = context.getHttpMethod().getStatusLine();
        String reason = null;

        if (statusLine != null)
            reason = statusLine.toString();

        if (reason == null || "".equals(reason))
            reason = String.valueOf(statusCode);

        ProxyException pe = new ProxyException();
        pe.setMessage(STATUS_ERROR, new Object[] { reason });
        pe.setCode(ProxyException.CODE_SERVER_PROXY_REQUEST_FAILED);
        pe.setDetails(STATUS_ERROR, "1", new Object[] { reason });
        pe.setStatusCode(statusCode);
        throw pe;
    }
}
 
开发者ID:apache,项目名称:flex-blazeds,代码行数:24,代码来源:ResponseFilter.java


示例5: curl

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
public String curl(String path) throws IOException {
    GetMethod method = new GetMethod(path);
    byte[] responseBody;
    StatusLine statusLine;
    try {
        client.executeMethod(method);

        responseBody = method.getResponseBody();
        statusLine = method.getStatusLine();
        if (statusLine.getStatusCode() == 200) {
            return new String(responseBody);
        } else {
            return null;
        }
    } finally {
        method.releaseConnection();
    }
}
 
开发者ID:jivesoftware,项目名称:jive-utils,代码行数:19,代码来源:Curl.java


示例6: adaptWARCHTTPResponse

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
private CaptureSearchResult adaptWARCHTTPResponse(CaptureSearchResult result,
		WARCRecord rec) throws IOException {

	ArchiveRecordHeader header = rec.getHeader();
	// need to parse the documents HTTP message and headers here: WARCReader
	// does not implement this... yet..
	
       byte [] statusBytes = HttpParser.readRawLine(rec);
       int eolCharCount = getEolCharsCount(statusBytes);
       if (eolCharCount <= 0) {
           throw new RecoverableIOException("Failed to read http status where one " +
                   " was expected: " + 
                   ((statusBytes == null) ? "(null)" : new String(statusBytes)));
       }
       String statusLine = EncodingUtil.getString(statusBytes, 0,
           statusBytes.length - eolCharCount, ARCConstants.DEFAULT_ENCODING);
       if ((statusLine == null) ||
               !StatusLine.startsWithHTTP(statusLine)) {
          throw new RecoverableIOException("Failed parse of http status line.");
       }
       StatusLine status = new StatusLine(statusLine);
	result.setHttpCode(String.valueOf(status.getStatusCode()));
       
	Header[] headers = HttpParser.parseHeaders(rec,
               ARCConstants.DEFAULT_ENCODING);

	
	annotater.annotateHTTPContent(result,rec,headers,header.getMimetype());

	return result;
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:32,代码来源:NetarchiveSuiteWARCRecordToSearchResultAdapter.java


示例7: testGetStatusLine

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
@Test
public void testGetStatusLine() throws HttpException {
    String statusLineString = "HTTP/1.0 199 Status Text";
    HttpMethod method = mock(HttpMethod.class);
    StatusLine statusLine = new StatusLine(statusLineString);
    when(method.getStatusLine()).thenReturn(statusLine);

    ChatterResponse response = new ChatterResponse(method);
    assertEquals(statusLineString, response.getStatusLine());
}
 
开发者ID:forcedotcom,项目名称:JavaChatterRESTApi,代码行数:11,代码来源:ChatterResponseTest.java


示例8: getStatusLine

import org.apache.commons.httpclient.StatusLine; //导入依赖的package包/类
/**
 * Provides access to the response status line.
 * 
 * @return the status line object from the latest response.
 * @since 2.0
 */
public StatusLine getStatusLine()
{
	return statusLine;
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:11,代码来源:HttpResponseTo.java



注:本文中的org.apache.commons.httpclient.StatusLine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TestTokenSecretManager类代码示例发布时间:2022-05-22
下一篇:
Java StringMap类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap