use of com.github.kevinsawicki.http.HttpRequest in project domain_hunter_pro by bit4woo.
the class VMP method upload.
public static boolean upload(String ApiUrl, HashMap<String, String> header, String jsonData) {
HttpRequest request = HttpRequest.post(ApiUrl);
// request.useProxy("localhost", 8080);//注意burp启用HTTP2的功能,会影响返回包的解析
request.trustAllCerts();
request.headers(header);
request = request.send(jsonData);
String body = "";
request.body(body);
int code = request.code();
// System.out.print(code);
if (code == 201 || code == 200) {
System.out.println(jsonData + " " + true);
return true;
} else {
System.out.println(jsonData + " code:" + code + " body:" + body);
return false;
}
}
use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class AuthImageDownloader method getStreamFromNetwork.
@Override
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
HttpRequest req = HttpRequest.get(imageUri, null, false).readTimeout(readTimeout).connectTimeout(connectTimeout).followRedirects(true).header("Authorization", "Token " + ((Account) extra).token);
HttpURLConnection conn = req.getConnection();
if (conn instanceof HttpsURLConnection) {
// Tell HttpRequest to trust all hosts, and then the user will get a dialog
// where he needs to confirm the SSL certificate for the account,
// and the accepted certificate will be stored, so he is not prompted to accept later on.
// This is handled by SSLTrustManager and CertsManager
req.trustAllHosts();
HttpsURLConnection sconn = (HttpsURLConnection) conn;
sconn.setSSLSocketFactory(SSLTrustManager.instance().getSSLSocketFactory((Account) extra));
}
return new FlushedInputStream(new BufferedInputStream(req.stream()));
}
use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class SeafConnection method rename.
public Pair<String, String> rename(String repoID, String path, String newName, boolean isdir) throws SeafException {
try {
Map<String, Object> params = Maps.newHashMap();
params.put("p", encodeUriComponent(path).replaceAll("\\+", "%20"));
params.put("reloaddir", "true");
String suffix = isdir ? "/dir/" : "/file/";
HttpRequest req = prepareApiPostRequest("api2/repos/" + repoID + suffix, true, params);
req.form("operation", "rename");
req.form("newname", newName);
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);
String newDirID = req.header("oid");
if (newDirID == null) {
return null;
}
String content = new String(req.bytes(), "UTF-8");
if (content.length() == 0) {
return null;
}
return new Pair<String, String>(newDirID, content);
} catch (SeafException e) {
throw e;
} catch (UnsupportedEncodingException e) {
throw SeafException.encodingException;
} catch (HttpRequestException e) {
throw getSeafExceptionFromHttpRequestException(e);
}
}
use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class SeafConnection method setPassword.
// set password for an encrypted repo
public boolean setPassword(String repoID, String passwd) throws SeafException {
try {
HttpRequest req = prepareApiPostRequest("api2/repos/" + repoID + "/", true, null);
req.form("password", passwd);
checkRequestResponseStatus(req, HttpURLConnection.HTTP_OK);
return true;
} catch (SeafException e) {
Log.d(DEBUG_TAG, "Set Password err: " + e.getCode());
throw e;
} catch (Exception e) {
Log.d(DEBUG_TAG, "Exception in setPassword ");
e.printStackTrace();
}
return false;
}
use of com.github.kevinsawicki.http.HttpRequest in project seadroid by haiwen.
the class SeafConnection method prepareApiDeleteRequest.
private HttpRequest prepareApiDeleteRequest(String apiPath, Map<String, ?> params) throws HttpRequestException {
HttpRequest req = HttpRequest.delete(account.server + apiPath, params, false).followRedirects(true).connectTimeout(CONNECTION_TIMEOUT);
req.header("Authorization", "Token " + account.token);
return prepareHttpsCheck(req);
}
Aggregations