add CommonRequest.header
This commit is contained in:
@ -34,6 +34,21 @@ public class CommonRequest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommonRequest header(String key, String value) {
|
||||||
|
request.addHeader(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonRequest token(String token) {
|
||||||
|
request.addHeader("Token", token);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonRequest language(String langHeader) {
|
||||||
|
request.addHeader("Accept-Language", langHeader);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String asString() throws IOException {
|
public String asString() throws IOException {
|
||||||
return request.execute().returnContent().asString();
|
return request.execute().returnContent().asString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,21 @@ public class FileRequest extends CommonRequest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileRequest header(String key, String value) {
|
||||||
|
request.addHeader(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileRequest token(String token) {
|
||||||
|
request.addHeader("Token", token);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileRequest language(String langHeader) {
|
||||||
|
request.addHeader("Accept-Language", langHeader);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void toFile(String path, String fileName) throws IOException, NoPermissionException {
|
public void toFile(String path, String fileName) throws IOException, NoPermissionException {
|
||||||
toFile(new File(IO.fitPath(path) + fileName));
|
toFile(new File(IO.fitPath(path) + fileName));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,21 @@ public class GsonRequest extends CommonRequest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GsonRequest header(String key, String value) {
|
||||||
|
request.addHeader(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GsonRequest token(String token) {
|
||||||
|
request.addHeader("Token", token);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GsonRequest language(String langHeader) {
|
||||||
|
request.addHeader("Accept-Language", langHeader);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public GsonRequest body(Object object) {
|
public GsonRequest body(Object object) {
|
||||||
request.bodyString(getGson().toJson(object), ContentType.APPLICATION_JSON);
|
request.bodyString(getGson().toJson(object), ContentType.APPLICATION_JSON);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@ -48,6 +48,21 @@ public class ProgressiveRequest extends FileRequest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProgressiveRequest header(String key, String value) {
|
||||||
|
request.addHeader(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressiveRequest token(String token) {
|
||||||
|
request.addHeader("Token", token);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProgressiveRequest language(String langHeader) {
|
||||||
|
request.addHeader("Accept-Language", langHeader);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toFile(Path outputPath) throws IOException, NoPermissionException {
|
public void toFile(Path outputPath) throws IOException, NoPermissionException {
|
||||||
processResponse(request.execute(), IO.getOutputStream(outputPath.toFile()));
|
processResponse(request.execute(), IO.getOutputStream(outputPath.toFile()));
|
||||||
|
|||||||
@ -34,6 +34,21 @@ public class TimiRequest extends GsonRequest {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimiRequest header(String key, String value) {
|
||||||
|
request.addHeader(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimiRequest token(String token) {
|
||||||
|
request.addHeader("Token", token);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TimiRequest language(String langHeader) {
|
||||||
|
request.addHeader("Accept-Language", langHeader);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimiRequest body(Object object) {
|
public TimiRequest body(Object object) {
|
||||||
super.body(object);
|
super.body(object);
|
||||||
|
|||||||
Reference in New Issue
Block a user