cc.kebei.expands.request.http.HttpRequest Maven / Gradle / Ivy
package cc.kebei.expands.request.http;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
/**
* http请求
* Created by Kebei on 16-6-23.
*/
public interface HttpRequest extends Closeable {
HttpRequest before(Callback callback);
HttpRequest after(Callback callback);
HttpRequest encode(String encode);
HttpRequest contentType(String type);
HttpRequest param(String name, String value);
HttpRequest params(Map params);
HttpRequest header(String name, String value);
HttpRequest headers(Map headers);
HttpRequest requestBody(String body);
HttpRequest resultAsJsonString();
HttpRequest cookie(String cookie);
HttpDownloader download() throws IOException;
Response upload(String paramName, File file) throws IOException;
default Response upload(String paramName, InputStream inputStream) throws IOException {
return upload(paramName, inputStream, paramName);
}
Response upload(String paramName, InputStream inputStream, String fileName) throws IOException;
Response upload(File file) throws IOException;
Response get() throws IOException;
Response post() throws IOException;
Response put() throws IOException;
Response delete() throws IOException;
Response patch() throws IOException;
}