本文整理匯總了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;
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}