use of com.reprezen.kaizen.oasparser.model3.RequestBody in project athena-java-sdk by uniubi-uface.
the class DefaultUniUbiHttpClient method buildRequest.
private Request buildRequest(String url, Object requestBody, Map<String, String> headers) {
// 创建请求header
Headers.Builder headerBuilder = new Headers.Builder();
if (headers != null) {
headers.forEach(headerBuilder::add);
}
Headers header = headerBuilder.build();
// 创建请求参数内容
String bodyContent = requestConverter.converter(requestBody);
RequestBody body = RequestBody.create(SDK_UNIFY_CONTENT_TYPE, bodyContent);
// 创建请求对象
return new Request.Builder().url(url).post(body).headers(header).build();
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project files-sdk-java by Files-com.
the class FilesOkHttpApi method putBufferedInputStream.
@Override
public long putBufferedInputStream(String url, HttpMethods.RequestMethods requestType, String name, BufferedInputStream inputStream) throws IOException {
String uri = ModelUtils.forceMandatoryUriEncode(url);
MediaType type = MediaType.parse("application/octet-stream");
Request.Builder request = new Request.Builder();
request.addHeader("Content-type", "application/octet-stream");
request.url(uri);
RequestBody body = create(type, inputStream);
updateRequestWithHttpMethod(request, body, requestType);
Response response = FilesHttpClient.getHttpClient().newCall(request.build()).execute();
return 0;
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project mollyim-android by mollyim.
the class PushServiceSocket method uploadToCdn0.
private byte[] uploadToCdn0(String path, String acl, String key, String policy, String algorithm, String credential, String date, String signature, InputStream data, String contentType, long length, OutputStreamFactory outputStreamFactory, ProgressListener progressListener, CancelationSignal cancelationSignal) throws PushNetworkException, NonSuccessfulResponseCodeException {
ConnectionHolder connectionHolder = getRandom(cdnClientsMap.get(0), random);
OkHttpClient okHttpClient = connectionHolder.getClient().newBuilder().connectTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS).readTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS).build();
DigestingRequestBody file = new DigestingRequestBody(data, outputStreamFactory, contentType, length, progressListener, cancelationSignal, 0);
RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("acl", acl).addFormDataPart("key", key).addFormDataPart("policy", policy).addFormDataPart("Content-Type", contentType).addFormDataPart("x-amz-algorithm", algorithm).addFormDataPart("x-amz-credential", credential).addFormDataPart("x-amz-date", date).addFormDataPart("x-amz-signature", signature).addFormDataPart("file", "file", file).build();
Request.Builder request = new Request.Builder().url(connectionHolder.getUrl() + "/" + path).post(requestBody);
if (connectionHolder.getHostHeader().isPresent()) {
request.addHeader("Host", connectionHolder.getHostHeader().get());
}
Call call = okHttpClient.newCall(request.build());
synchronized (connections) {
connections.add(call);
}
try {
Response response;
try {
response = call.execute();
} catch (IOException e) {
throw new PushNetworkException(e);
}
if (response.isSuccessful())
return file.getTransmittedDigest();
else
throw new NonSuccessfulResponseCodeException(response.code(), "Response: " + response);
} finally {
synchronized (connections) {
connections.remove(call);
}
}
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project mollyim-android by mollyim.
the class PushServiceSocket method makeCallingRequest.
public CallingResponse makeCallingRequest(long requestId, String url, String httpMethod, List<Pair<String, String>> headers, byte[] body) {
ConnectionHolder connectionHolder = getRandom(serviceClients, random);
OkHttpClient okHttpClient = connectionHolder.getClient().newBuilder().followRedirects(false).connectTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS).readTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS).build();
RequestBody requestBody = body != null ? RequestBody.create(null, body) : null;
Request.Builder builder = new Request.Builder().url(url).method(httpMethod, requestBody);
if (headers != null) {
for (Pair<String, String> header : headers) {
builder.addHeader(header.first(), header.second());
}
}
Request request = builder.build();
for (int i = 0; i < MAX_FOLLOW_UPS; i++) {
try (Response response = okHttpClient.newCall(request).execute()) {
int responseStatus = response.code();
if (responseStatus != 307) {
return new CallingResponse.Success(requestId, responseStatus, response.body() != null ? response.body().bytes() : new byte[0]);
}
String location = response.header("Location");
HttpUrl newUrl = location != null ? request.url().resolve(location) : null;
if (newUrl != null) {
request = request.newBuilder().url(newUrl).build();
} else {
return new CallingResponse.Error(requestId, new IOException("Received redirect without a valid Location header"));
}
} catch (IOException e) {
Log.w(TAG, "Exception during ringrtc http call.", e);
return new CallingResponse.Error(requestId, e);
}
}
Log.w(TAG, "Calling request max redirects exceeded");
return new CallingResponse.Error(requestId, new IOException("Redirect limit exceeded"));
}
use of com.reprezen.kaizen.oasparser.model3.RequestBody in project Stundenplaner.FHE_EAH by avinotec.
the class NetworkHandler method registerTimeTableChanges.
/**
* @param json
* @param _Callback
*/
public void registerTimeTableChanges(final String json, final Callback<ResponseModel> _Callback) {
Assert.assertTrue(mApi != null);
final RequestBody body = RequestBody.create(json, MediaType.parse("application/json"));
mApi.registerTimeTableChanges(body).enqueue(_Callback);
}
Aggregations