当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatus.getStatusText方法代码示例

本文整理汇总了Java中org.apache.commons.httpclient.HttpStatus.getStatusText方法的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.getStatusText方法的具体用法?Java HttpStatus.getStatusText怎么用?Java HttpStatus.getStatusText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.httpclient.HttpStatus的用法示例。


在下文中一共展示了HttpStatus.getStatusText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResponse

import org.apache.commons.httpclient.HttpStatus; //导入方法依赖的package包/类
public static SimpleResponse getResponse(int statusCode) {
    Integer code = new Integer(statusCode);
    SimpleResponse response = (SimpleResponse)responses.get(code);
    if (response == null) {
        response = new SimpleResponse();
        response.setStatusLine(HttpVersion.HTTP_1_0, statusCode);
        response.setHeader(new Header("Content-Type", "text/plain; charset=US-ASCII"));

        String s = HttpStatus.getStatusText(statusCode);
        if (s == null) {
            s = "Error " + statusCode;
        }
        response.setBodyString(s);
        response.addHeader(new Header("Connection", "close"));
        response.addHeader(new Header("Content-Lenght", Integer.toString(s.length())));
        responses.put(code, response);
    }
    return response;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:20,代码来源:ErrorResponse.java

示例2: itemResponse

import org.apache.commons.httpclient.HttpStatus; //导入方法依赖的package包/类
private String itemResponse(String title, String code, String description) {
    StringBuilder sb = new StringBuilder("");
    String status = "";
    if (!code.equals("default")) {
        status = HttpStatus.getStatusText(Integer.parseInt(code));
    }
    sb.append(String.format("%s : **%s %s**\n", title, code, status));
    sb.append(description(description));
    return sb.toString();
}
 
开发者ID:quen2404,项目名称:openapi-diff,代码行数:11,代码来源:MarkdownRender.java

示例3: itemResponse

import org.apache.commons.httpclient.HttpStatus; //导入方法依赖的package包/类
private String itemResponse(String title, String code) {
    StringBuilder sb = new StringBuilder();
    String status = "";
    if (!code.equals("default")) {
        status = HttpStatus.getStatusText(Integer.parseInt(code));
    }
    sb.append(StringUtils.repeat(' ', 4)).append("- ").append(title).append(code)
            .append(' ').append(status).append(System.lineSeparator());
    return sb.toString();
}
 
开发者ID:quen2404,项目名称:openapi-diff,代码行数:11,代码来源:ConsoleRender.java

示例4: setStatusLine

import org.apache.commons.httpclient.HttpStatus; //导入方法依赖的package包/类
public void setStatusLine(final HttpVersion ver, int statuscode, final String phrase) {
    if (ver == null) {
        throw new IllegalArgumentException("HTTP version may not be null");
    }
    if (statuscode <= 0) {
        throw new IllegalArgumentException("Status code may not be negative or zero");
    }
    this.ver = ver;
    this.statuscode = statuscode;
    if (phrase != null) {
        this.phrase = phrase;
    } else {
        this.phrase = HttpStatus.getStatusText(statuscode);
    }
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:16,代码来源:SimpleResponse.java

示例5: sendToZoho

import org.apache.commons.httpclient.HttpStatus; //导入方法依赖的package包/类
/**
 *
 */
private Map<String, String> sendToZoho(String zohoUrl, String nodeUuid, String lang) throws PathNotFoundException,
		AccessDeniedException, RepositoryException, DatabaseException, IOException, OKMException {
	Map<String, String> result = new HashMap<String, String>();
	File tmp = null;

	try {
		String path = OKMRepository.getInstance().getNodePath(null, nodeUuid);
		String fileName = PathUtils.getName(path);
		tmp = File.createTempFile("okm", ".tmp");
		InputStream is = OKMDocument.getInstance().getContent(null, path, false);
		Document doc = OKMDocument.getInstance().getProperties(null, path);
		FileOutputStream fos = new FileOutputStream(tmp);
		IOUtils.copy(is, fos);
		fos.flush();
		fos.close();

		String id = UUID.randomUUID().toString();
		String saveurl = Config.APPLICATION_BASE + "/extension/ZohoFileUpload";
		Part[] parts = {new FilePart("content", tmp), new StringPart("apikey", Config.ZOHO_API_KEY),
				new StringPart("output", "url"), new StringPart("mode", "normaledit"),
				new StringPart("filename", fileName), new StringPart("skey", Config.ZOHO_SECRET_KEY),
				new StringPart("lang", lang), new StringPart("id", id),
				new StringPart("format", getFormat(doc.getMimeType())), new StringPart("saveurl", saveurl)};

		PostMethod filePost = new PostMethod(zohoUrl);
		filePost.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "UTF-8");
		filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));
		HttpClient client = new HttpClient();
		client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
		int status = client.executeMethod(filePost);

		if (status == HttpStatus.SC_OK) {
			log.debug("OK: " + filePost.getResponseBodyAsString());
			ZohoToken zot = new ZohoToken();
			zot.setId(id);
			zot.setUser(getThreadLocalRequest().getRemoteUser());
			zot.setNode(nodeUuid);
			zot.setCreation(Calendar.getInstance());
			ZohoTokenDAO.create(zot);

			// Get the response
			BufferedReader rd = new BufferedReader(new InputStreamReader(filePost.getResponseBodyAsStream()));
			String line;

			while ((line = rd.readLine()) != null) {
				if (line.startsWith("URL=")) {
					result.put("url", line.substring(4));
					result.put("id", id);
					break;
				}
			}

			rd.close();
		} else {
			String error = HttpStatus.getStatusText(status) + "\n\n" + filePost.getResponseBodyAsString();
			log.error("ERROR: {}", error);
			throw new OKMException(ErrorCode.get(ErrorCode.ORIGIN_OKMZohoService, ErrorCode.CAUSE_Zoho), error);
		}
	} finally {
		FileUtils.deleteQuietly(tmp);
	}

	return result;
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:68,代码来源:ZohoServlet.java


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