List of usage examples for com.squareup.okhttp Response newBuilder
public Builder newBuilder()
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call getJobCall(String jobId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'jobId' is set if (jobId == null) { throw new ApiException("Missing the required parameter 'jobId' when calling getJob(Async)"); }// w w w. ja va 2s . c om // create path and map variables String localVarPath = "/template/processor/0.1/jobs/{jobId}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "jobId" + "\\}", apiClient.escapeString(jobId.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json;charset=UTF-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call getJobsCall(List<String> status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/template/processor/0.1/jobs".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); if (status != null) localVarQueryParams.addAll(apiClient.parameterToPairs("multi", "status", status)); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json;charset=UTF-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override//from w w w . j ava 2 s . c o m public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call getResultStreamByIdCall(String jobId, String streamId, OutputSettings outputSettings, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = outputSettings; // verify the required parameter 'jobId' is set if (jobId == null) { throw new ApiException( "Missing the required parameter 'jobId' when calling getResultStreamById(Async)"); }/* w w w.ja v a 2 s. c om*/ // verify the required parameter 'streamId' is set if (streamId == null) { throw new ApiException( "Missing the required parameter 'streamId' when calling getResultStreamById(Async)"); } // create path and map variables String localVarPath = "/template/processor/0.1/jobs/{jobId}/result/file/{streamId}" .replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "jobId" + "\\}", apiClient.escapeString(jobId.toString())) .replaceAll("\\{" + "streamId" + "\\}", apiClient.escapeString(streamId.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/octet-stream" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json;charset=UTF-8" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call getResultStreamsAsContainerCall(String jobId, OutputSettings outputSettings, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = outputSettings; // verify the required parameter 'jobId' is set if (jobId == null) { throw new ApiException( "Missing the required parameter 'jobId' when calling getResultStreamsAsContainer(Async)"); }//from ww w .j ava2s .c o m // create path and map variables String localVarPath = "/template/processor/0.1/jobs/{jobId}/result/container" .replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "jobId" + "\\}", apiClient.escapeString(jobId.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/octet-stream" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json;charset=UTF-8" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call getTemplateContextCall(String templateId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'templateId' is set if (templateId == null) { throw new ApiException( "Missing the required parameter 'templateId' when calling getTemplateContext(Async)"); }// w w w.ja va 2 s . co m // create path and map variables String localVarPath = "/template/processor/0.1/templates/{templateId}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "templateId" + "\\}", apiClient.escapeString(templateId.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json;charset=UTF-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call submitJobCall(MergeSettings mergesettings, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = mergesettings; // verify the required parameter 'mergesettings' is set if (mergesettings == null) { throw new ApiException("Missing the required parameter 'mergesettings' when calling submitJob(Async)"); }/*from ww w. ja v a2 s . co m*/ // create path and map variables String localVarPath = "/template/processor/0.1/jobs".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json;charset=UTF-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json;charset=UTF-8" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call updateTemplateContextCall(TemplateContextRequest templateContextRequest, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = templateContextRequest; // verify the required parameter 'templateContextRequest' is set if (templateContextRequest == null) { throw new ApiException( "Missing the required parameter 'templateContextRequest' when calling updateTemplateContext(Async)"); }//w ww . ja v a 2s . co m // create path and map variables String localVarPath = "/template/processor/0.1/templates".replaceAll("\\{format\\}", "json"); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json;charset=UTF-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "application/json;charset=UTF-8" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.sphereon.sdk.template.processor.api.AllApi.java
License:Apache License
private com.squareup.okhttp.Call uploadTemplateFileCall(String templateId, File stream, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'templateId' is set if (templateId == null) { throw new ApiException( "Missing the required parameter 'templateId' when calling uploadTemplateFile(Async)"); }/*from w w w .ja v a 2 s .c o m*/ // verify the required parameter 'stream' is set if (stream == null) { throw new ApiException( "Missing the required parameter 'stream' when calling uploadTemplateFile(Async)"); } // create path and map variables String localVarPath = "/template/processor/0.1/templates/{templateId}".replaceAll("\\{format\\}", "json") .replaceAll("\\{" + "templateId" + "\\}", apiClient.escapeString(templateId.toString())); List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); if (stream != null) localVarFormParams.put("stream", stream); final String[] localVarAccepts = { "application/json;charset=UTF-8" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); final String[] localVarContentTypes = { "multipart/form-data" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); if (progressListener != null) { apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { @Override public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); return originalResponse.newBuilder() .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build(); } }); } String[] localVarAuthNames = new String[] { "oauth2schema" }; return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); }
From source file:com.taobao.weex.devtools.inspector.network.OkHttpInterceptor.java
License:Open Source License
@Override public Response intercept(Chain chain) throws IOException { String requestId = String.valueOf(mNextRequestId.getAndIncrement()); Request request = chain.request(); RequestBodyHelper requestBodyHelper = null; if (mEventReporter.isEnabled()) { requestBodyHelper = new RequestBodyHelper(mEventReporter, requestId); OkHttpInspectorRequest inspectorRequest = new OkHttpInspectorRequest(requestId, request, requestBodyHelper);/*from w w w .j a va2s . co m*/ mEventReporter.requestWillBeSent(inspectorRequest); } Response response; try { response = chain.proceed(request); } catch (IOException e) { if (mEventReporter.isEnabled()) { mEventReporter.httpExchangeFailed(requestId, e.toString()); } throw e; } if (mEventReporter.isEnabled()) { if (requestBodyHelper != null && requestBodyHelper.hasBody()) { requestBodyHelper.reportDataSent(); } Connection connection = chain.connection(); mEventReporter .responseHeadersReceived(new OkHttpInspectorResponse(requestId, request, response, connection)); ResponseBody body = response.body(); MediaType contentType = null; InputStream responseStream = null; if (body != null) { contentType = body.contentType(); responseStream = body.byteStream(); } responseStream = mEventReporter.interpretResponseStream(requestId, contentType != null ? contentType.toString() : null, response.header("Content-Encoding"), responseStream, new DefaultResponseHandler(mEventReporter, requestId)); if (responseStream != null) { response = response.newBuilder().body(new ForwardingResponseBody(body, responseStream)).build(); } } return response; }
From source file:com.xing.api.CallSpec.java
License:Apache License
/** Parsers the OkHttp raw response and returns an response ready to be consumed by the caller. */ @SuppressWarnings("MagicNumber") // These codes are specific to this method and to the http protocol. private Response<RT, ET> parseResponse(com.squareup.okhttp.Response rawResponse) throws IOException { ResponseBody rawBody = rawResponse.body(); // Remove the body's source (the only stateful object) so we can pass the response along. rawResponse = rawResponse.newBuilder() .body(new NoContentResponseBody(rawBody.contentType(), rawBody.contentLength())).build(); ExceptionCatchingRequestBody catchingBody = new ExceptionCatchingRequestBody(rawBody); int code = rawResponse.code(); if (code < 200 || code >= 300) { try {/*from w w w . j a v a 2s . c o m*/ // Buffer the entire body to avoid future I/O. ET errorBody = parseBody(errorType, catchingBody); return Response.error(errorBody, rawResponse); } catch (RuntimeException e) { // If the underlying source threw an exception, propagate that, rather than indicating it was // a runtime exception. catchingBody.throwIfCaught(); throw e; } finally { closeQuietly(catchingBody); } } // No need to parse the response body since the response should not contain a body. if (code == 204 || code == 205) { return Response.success(null, rawResponse); } try { RT body = parseBody(responseType, catchingBody); return Response.success(body, rawResponse); } catch (RuntimeException e) { // If the underlying source threw an exception, propagate that, rather than indicating it was // a runtime exception. catchingBody.throwIfCaught(); throw e; } finally { closeQuietly(catchingBody); } }