當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。