• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ContentProducer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.http.entity.ContentProducer的典型用法代码示例。如果您正苦于以下问题:Java ContentProducer类的具体用法?Java ContentProducer怎么用?Java ContentProducer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContentProducer类属于org.apache.http.entity包,在下文中一共展示了ContentProducer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doPost

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Send a HTTP POST request to the specified URL
 *
 * @param url         Target endpoint URL
 * @param headers     Any HTTP headers that should be added to the request
 * @param payload     Content payload that should be sent
 * @param contentType Content-type of the request
 * @return Returned HTTP response
 * @throws IOException If an error occurs while making the invocation
 */
public HttpResponse doPost(String url, final Map<String, String> headers,
                           final String payload, String contentType) throws IOException {
    HttpUriRequest request = new HttpPost(url);
    setHeaders(headers, request);
    HttpEntityEnclosingRequest entityEncReq = (HttpEntityEnclosingRequest) request;
    final boolean zip = headers != null && "gzip".equals(headers.get(HttpHeaders.CONTENT_ENCODING));

    EntityTemplate ent = new EntityTemplate(new ContentProducer() {
        public void writeTo(OutputStream outputStream) throws IOException {
            OutputStream out = outputStream;
            if (zip) {
                out = new GZIPOutputStream(outputStream);
            }
            out.write(payload.getBytes());
            out.flush();
            out.close();
        }
    });
    ent.setContentType(contentType);
    if (zip) {
        ent.setContentEncoding("gzip");
    }
    entityEncReq.setEntity(ent);
    return client.execute(request);
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:36,代码来源:SimpleHttpClient.java


示例2: doPatch

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Send a HTTP PATCH request to the specified URL
 *
 * @param url         Target endpoint URL
 * @param headers     Any HTTP headers that should be added to the request
 * @param payload     Content payload that should be sent
 * @param contentType Content-type of the request
 * @return Returned HTTP response
 * @throws IOException If an error occurs while making the invocation
 */
public HttpResponse doPatch(String url, final Map<String, String> headers,
                            final String payload, String contentType) throws IOException {
    HttpUriRequest request = new HttpPatch(url);
    setHeaders(headers, request);
    HttpEntityEnclosingRequest entityEncReq = (HttpEntityEnclosingRequest) request;
    final boolean zip = headers != null && "gzip".equals(headers.get(HttpHeaders.CONTENT_ENCODING));

    EntityTemplate ent = new EntityTemplate(new ContentProducer() {
        public void writeTo(OutputStream outputStream) throws IOException {
            OutputStream out = outputStream;
            if (zip) {
                out = new GZIPOutputStream(outputStream);
            }
            out.write(payload.getBytes());
            out.flush();
            out.close();
        }
    });
    ent.setContentType(contentType);
    if (zip) {
        ent.setContentEncoding("gzip");
    }
    entityEncReq.setEntity(ent);
    return client.execute(request);
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:36,代码来源:SimpleHttpClient.java


示例3: doPut

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Send a HTTP PUT request to the specified URL
 *
 * @param url         Target endpoint URL
 * @param headers     Any HTTP headers that should be added to the request
 * @param payload     Content payload that should be sent
 * @param contentType Content-type of the request
 * @return Returned HTTP response
 * @throws IOException If an error occurs while making the invocation
 */
public HttpResponse doPut(String url, final Map<String, String> headers,
                          final String payload, String contentType) throws IOException {
    HttpUriRequest request = new HttpPut(url);
    setHeaders(headers, request);
    HttpEntityEnclosingRequest entityEncReq = (HttpEntityEnclosingRequest) request;
    final boolean zip = headers != null && "gzip".equals(headers.get(HttpHeaders.CONTENT_ENCODING));

    EntityTemplate ent = new EntityTemplate(new ContentProducer() {
        public void writeTo(OutputStream outputStream) throws IOException {
            OutputStream out = outputStream;
            if (zip) {
                out = new GZIPOutputStream(outputStream);
            }
            out.write(payload.getBytes());
            out.flush();
            out.close();
        }
    });
    ent.setContentType(contentType);
    if (zip) {
        ent.setContentEncoding("gzip");
    }
    entityEncReq.setEntity(ent);
    return client.execute(request);
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:36,代码来源:SimpleHttpClient.java


示例4: handle

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
public void handle(
		final HttpRequest request, 
		final HttpResponse response,
		final HttpContext context) throws HttpException, IOException {

	final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
	if (!method.equals("GET") && !method.equals("HEAD")) {
		throw new MethodNotSupportedException(method + " method not supported"); 
	}

	final EntityTemplate body = new EntityTemplate(new ContentProducer() {
		public void writeTo(final OutputStream outstream) throws IOException {
			OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8"); 
			writer.write(mJSON);
			writer.flush();
		}
	});

	response.setStatusCode(HttpStatus.SC_OK);
	body.setContentType("text/json; charset=UTF-8");
	response.setEntity(body);

}
 
开发者ID:ghazi94,项目名称:Android_CCTV,代码行数:24,代码来源:ModInternationalization.java


示例5: handle

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
public void handle(HttpRequest request, HttpResponse response, HttpContext arg2) throws HttpException, IOException {

			if (request.getRequestLine().getMethod().equals("POST")) {

				// Retrieve the POST content
				HttpEntityEnclosingRequest post = (HttpEntityEnclosingRequest) request;
				byte[] entityContent = EntityUtils.toByteArray(post.getEntity());
				String content = new String(entityContent, Charset.forName("UTF-8"));

				// Execute the request
				final String json = RequestHandler.handle(content);

				// Return the response
				EntityTemplate body = new EntityTemplate(new ContentProducer() {
					public void writeTo(final OutputStream outstream) throws IOException {
						OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8");
						writer.write(json);
						writer.flush();
					}
				});
				response.setStatusCode(HttpStatus.SC_OK);
				body.setContentType("application/json; charset=UTF-8");
				response.setEntity(body);
			}

		}
 
开发者ID:ghazi94,项目名称:Android_CCTV,代码行数:27,代码来源:CustomHttpServer.java


示例6: toContentProducer

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Wraps an XML writing into a ContentProducer for
 * lazy serialization.
 * @param doc the XML document to wrap.
 * @return The ContentProducer.
 */
public static ContentProducer toContentProducer(final Document doc) {
    return out -> {
        try {
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer transformer = tf.newTransformer();
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(OutputKeys.ENCODING, UTF8);
            transformer.setOutputProperty(OutputKeys.INDENT, "no");
            transformer.transform(
                new DOMSource(doc), new StreamResult(out));
        } catch (TransformerException te) {
            throw new IOException(te);
        }
    };
}
 
开发者ID:gdi-by,项目名称:downloadclient,代码行数:22,代码来源:XML.java


示例7: doPost

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Send a HTTP POST request to the specified URL
 *
 * @param url         Target endpoint URL
 * @param headers     Any HTTP headers that should be added to the request
 * @param payload     Content payload that should be sent
 * @param contentType Content-type of the request
 * @return Returned HTTP response
 * @throws IOException If an error occurs while making the invocation
 */
public HttpResponse doPost(String url, final Map<String, String> headers,
                           final String payload, String contentType) throws IOException {
    HttpUriRequest request = new HttpPost(url);
    setHeaders(headers, request);
    HttpEntityEnclosingRequest entityEncReq = (HttpEntityEnclosingRequest) request;
    final boolean zip = headers != null && "gzip".equals(headers.get(HttpHeaders.CONTENT_ENCODING));

    EntityTemplate ent = new EntityTemplate(new ContentProducer() {
        public void writeTo(OutputStream outputStream) throws IOException {
            OutputStream out = outputStream;
            if (zip) {
                out = new GZIPOutputStream(outputStream);
            }
            out.write(payload.getBytes(Charset.defaultCharset()));
            out.flush();
            out.close();
        }
    });
    ent.setContentType(contentType);
    if (zip) {
        ent.setContentEncoding("gzip");
    }
    entityEncReq.setEntity(ent);
    return client.execute(request);
}
 
开发者ID:wso2,项目名称:carbon-platform-integration,代码行数:36,代码来源:SimpleHttpClient.java


示例8: doPut

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Send a HTTP PUT request to the specified URL
 *
 * @param url         Target endpoint URL
 * @param headers     Any HTTP headers that should be added to the request
 * @param payload     Content payload that should be sent
 * @param contentType Content-type of the request
 * @return Returned HTTP response
 * @throws IOException If an error occurs while making the invocation
 */
public HttpResponse doPut(String url, final Map<String, String> headers,
                          final String payload, String contentType) throws IOException {
    HttpUriRequest request = new HttpPut(url);
    setHeaders(headers, request);
    HttpEntityEnclosingRequest entityEncReq = (HttpEntityEnclosingRequest) request;
    final boolean zip = headers != null && "gzip".equals(headers.get(HttpHeaders.CONTENT_ENCODING));

    EntityTemplate ent = new EntityTemplate(new ContentProducer() {
        public void writeTo(OutputStream outputStream) throws IOException {
            OutputStream out = outputStream;
            if (zip) {
                out = new GZIPOutputStream(outputStream);
            }
            out.write(payload.getBytes(Charset.defaultCharset()));
            out.flush();
            out.close();
        }
    });
    ent.setContentType(contentType);
    if (zip) {
        ent.setContentEncoding("gzip");
    }
    entityEncReq.setEntity(ent);
    return client.execute(request);
}
 
开发者ID:wso2,项目名称:carbon-platform-integration,代码行数:36,代码来源:SimpleHttpClient.java


示例9: doOptions

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Send a HTTP OPTIONS request to the specified URL
 *
 * @param url         Target endpoint URL
 * @param headers     Any HTTP headers that should be added to the request
 * @param payload     Content payload that should be sent
 * @param contentType Content-type of the request
 * @return Returned HTTP response
 * @throws IOException If an error occurs while making the invocation
 */
public HttpResponse doOptions(String url, final Map<String, String> headers,
                              final String payload, String contentType) throws IOException {
    HttpUriRequest request = new HttpOptions(url);
    setHeaders(headers, request);
    if(payload != null) {
        HttpEntityEnclosingRequest entityEncReq = (HttpEntityEnclosingRequest) request;
        final boolean zip = headers != null && "gzip".equals(headers.get(HttpHeaders.CONTENT_ENCODING));

        EntityTemplate ent = new EntityTemplate(new ContentProducer() {
            public void writeTo(OutputStream outputStream) throws IOException {
                OutputStream out = outputStream;
                if (zip) {
                    out = new GZIPOutputStream(outputStream);
                }
                out.write(payload.getBytes());
                out.flush();
                out.close();
            }
        });
        ent.setContentType(contentType);
        if (zip) {
            ent.setContentEncoding("gzip");
        }
        entityEncReq.setEntity(ent);
    }
    return client.execute(request);
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:38,代码来源:SimpleHttpClient.java


示例10: newContentProducer

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
protected ContentProducer newContentProducer(String contentType, List docs) {
  if ("text/csv".equals(contentType)) {
    return new CsvContentProducer(docs);
  } else if (PIPELINE_DOC_TYPE.equals(contentType) || "application/json".equals(contentType)) {
    return new JacksonContentProducer(jsonObjectMapper, docs);
  } else {
    throw new IllegalArgumentException("Content type "+contentType+" not supported! Use text/csv or "+PIPELINE_DOC_TYPE);
  }
}
 
开发者ID:lucidworks,项目名称:fusion-client-tools,代码行数:10,代码来源:FusionPipelineClient.java


示例11: toApacheContentProducer

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
private ContentProducer toApacheContentProducer(RepeatableContentProducer repeatableContentProducer)
{
    return (OutputStream outputStream) -> {
        try (InputStream inputStream = repeatableContentProducer.getInputStream()) {
            copyLarge(inputStream, outputStream);
        }
    };
}
 
开发者ID:prestodb,项目名称:tempto,代码行数:9,代码来源:WebHdfsClient.java


示例12: handle

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext httpContext) throws HttpException, IOException {
	String contentType;
       Integer code;
       Uri uri = Uri.parse(request.getRequestLine().getUri());
       String fileUri = URLDecoder.decode(uri.getLastPathSegment());

       final byte[] r;
       byte[] resp;
       AssetManager mgr = context.getAssets();
       try {
           resp = Utility.loadInputStreamAsByte(mgr.open(fileUri));
           contentType = Utility.getMimeTypeForFile(fileUri);
           code = HttpStatus.OK.getCode();
       } catch (IOException e){
           resp = Utility.loadInputStreamAsByte(mgr.open("notfound.html"));
           contentType = Utility.MIME_TYPES.get("html");
           code = HttpStatus.NOT_FOUND.getCode();
       }
       r=resp;

       HttpEntity entity = new EntityTemplate(new ContentProducer() {
   		public void writeTo(final OutputStream outstream) throws IOException {
               outstream.write(r);
              }
   	});

	((EntityTemplate)entity).setContentType(contentType);
       response.setStatusCode(code);
	response.setEntity(entity);
}
 
开发者ID:TheZ3ro,项目名称:Blackhole,代码行数:32,代码来源:AssetHandler.java


示例13: handle

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext httpContext) throws HttpException, IOException {
       String contentType;
       Integer code;
       Uri uri = Uri.parse(request.getRequestLine().getUri());

       String folder;
       List<String> s = uri.getPathSegments();
       String path = File.separator;
       for(int i=1;i<s.size()-1;i++) {
           path+=s.get(i)+File.separator;
       }
       folder = path;
       final File file = new File(Utility.BLACKHOLE_PATH +folder+s.get(s.size()-1));

       final byte[] r;
       byte[] resp;
       if(file.exists()){
           resp = Utility.loadFileAsByte(file.getAbsolutePath());
           contentType = Utility.getMimeTypeForFile(file.getName());
           code = HttpStatus.OK.getCode();
       }else{
           AssetManager mgr = context.getAssets();
           resp = Utility.loadInputStreamAsByte(mgr.open("notfound.html"));
           contentType = Utility.MIME_TYPES.get("html");
           code = HttpStatus.NOT_FOUND.getCode();
       }
       r=resp;

       HttpEntity entity = new EntityTemplate(new ContentProducer() {
           public void writeTo(final OutputStream outstream) throws IOException {
               outstream.write(r);
           }
       });

       ((EntityTemplate)entity).setContentType(contentType);
       response.setStatusCode(code);
       response.addHeader(HttpHeader.CONTENT_DISPOSITION, "attachment");
       response.setEntity(entity);
}
 
开发者ID:TheZ3ro,项目名称:Blackhole,代码行数:41,代码来源:FileHandler.java


示例14: forgeResponse

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
public HttpEntity forgeResponse(){
    HttpEntity entity = new EntityTemplate(new ContentProducer() {
        public void writeTo(final OutputStream outstream) throws IOException {
            outstream.write(response);
        }
    });

    ((EntityTemplate)entity).setContentType(contentType);
    return entity;
}
 
开发者ID:TheZ3ro,项目名称:Blackhole,代码行数:11,代码来源:ResponseForger.java


示例15: newContentProducer

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
protected ContentProducer newContentProducer(String contentType, List docs) {
  if ("text/csv".equals(contentType)) {
    return new CsvContentProducer(docs);
  } else if (JSON_CONTENT_TYPE.equals(contentType) || PIPELINE_DOC_CONTENT_TYPE.equals(contentType)) {
    return new JacksonContentProducer(jsonObjectMapper, docs);
  } else {
    throw new IllegalArgumentException("Content type "+contentType+
            " not supported! Use text/csv, application/json, or "+PIPELINE_DOC_CONTENT_TYPE);
  }
}
 
开发者ID:lucidworks,项目名称:solr-scale-tk,代码行数:11,代码来源:FusionPipelineClient.java


示例16: createEntity

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
private EntityTemplate createEntity() {
    return new EntityTemplate(new ContentProducer() {
        public void writeTo(OutputStream outputStream) throws IOException {
            OutputStreamWriter writer = new OutputStreamWriter(outputStream, "UTF-8");
            writer.write(payload);
            writer.flush();
        }
    });
}
 
开发者ID:wso2,项目名称:carbon-platform-integration,代码行数:10,代码来源:TestRequestHandler.java


示例17: updateResourceMetadata

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * Update (overwrite) the metadata of the resource identified by the given uri. The metadata will be serialised to
 * application/json and sent to the Apache Marmotta server. The given metadata will override any metadata
 * for the resource already existing on the server. The resource has to exist or be created before updating, otherwise
 * the method will throw a NotFoundException.
 *
 * @param uri        the URI of the resource to update
 * @param metadata   the metadata to upload to the resource
 * @throws IOException
 * @throws MarmottaClientException
 */
public void updateResourceMetadata(final String uri, final Metadata metadata) throws IOException, MarmottaClientException {
    HttpClient httpClient = HTTPUtil.createClient(config);

    HttpPut put = new HttpPut(getServiceUrl(uri));
    put.setHeader(CONTENT_TYPE, "application/rdf+json; rel=meta");
    ContentProducer cp = new ContentProducer() {
        @Override
        public void writeTo(OutputStream outstream) throws IOException {
            RDFJSONParser.serializeRDFJSON(ImmutableMap.of(uri, metadata), outstream);
        }
    };
    put.setEntity(new EntityTemplate(cp));

    try {
        
        HttpResponse response = httpClient.execute(put);

        switch(response.getStatusLine().getStatusCode()) {
            case 200:
                log.debug("metadata for resource {} updated",uri);
                break;
            case 415:
                log.error("server does not support metadata type application/json for resource {}, cannot update", uri);
                throw new ContentFormatException("server does not support metadata type application/json for resource "+uri);
            case 404:
                log.error("resource {} does not exist, cannot update", uri);
                throw new NotFoundException("resource "+uri+" does not exist, cannot update");
            default:
                log.error("error updating resource {}: {} {}",new Object[] {uri,response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
                throw new MarmottaClientException("error updating resource "+uri+": "+response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
        }

    } catch (UnsupportedEncodingException e) {
        log.error("could not encode URI parameter",e);
        throw new MarmottaClientException("could not encode URI parameter");
    } finally {
        put.releaseConnection();
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:51,代码来源:ResourceClient.java


示例18: uploadDataset

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
private void uploadDataset(final InputStream in, final String mimeType, HttpClient httpClient) throws IOException, URISyntaxException {
    HttpPost post = HTTPUtil.createPost(URL_UPLOAD_SERVICE, config);
    post.setHeader(CONTENT_TYPE, mimeType);

    ContentProducer cp = new ContentProducer() {
        @Override
        public void writeTo(OutputStream outstream) throws IOException {
            ByteStreams.copy(in,outstream);
        }
    };
    post.setEntity(new EntityTemplate(cp));

    ResponseHandler<Boolean> handler = new ResponseHandler<Boolean>() {
        @Override
        public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
            EntityUtils.consume(response.getEntity());
            switch(response.getStatusLine().getStatusCode()) {
                case 200:
                    log.debug("dataset uploaded updated successfully");
                    return true;
                case 412:
                    log.error("mime type {} not acceptable by import service",mimeType);
                    return false;
                default:
                    log.error("error uploading dataset: {} {}",new Object[] {response.getStatusLine().getStatusCode(),response.getStatusLine().getReasonPhrase()});
                    return false;
            }
        }
    };

    try {
        httpClient.execute(post, handler);
    } catch(IOException ex) {
        post.abort();
        throw ex;
    } finally {
        post.releaseConnection();
    }
}
 
开发者ID:apache,项目名称:marmotta,代码行数:40,代码来源:ImportClient.java


示例19: doPost

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
/**
 * 以POST方式请求(上传JSON串)
 * 
 * @param url
 *            接口地址
 * @param requestBody
 *            发送的请求数据包 JSON串
 * @return Message对象
 */
public static Message doPost(String url, final String requestBody) {
	Log.i(TAG, "POST:REQUEST URL IS --- " + url);
	HttpPost httpPost = new HttpPost(url);
	ContentProducer contentProducer = new ContentProducer() {
		public void writeTo(OutputStream outstream) throws IOException {
			Writer writer = new OutputStreamWriter(outstream, ENCODEING);
			writer.write(requestBody);
			writer.flush();
		}
	};
	HttpEntity entity = new EntityTemplate(contentProducer);
	httpPost.setEntity(entity);
	return executeRequest(httpPost);
}
 
开发者ID:yinghuihong,项目名称:android-json-http,代码行数:24,代码来源:HttpRequest.java


示例20: postDocsToPipeline

import org.apache.http.entity.ContentProducer; //导入依赖的package包/类
public void postDocsToPipeline(String hostAndPort, String pipelinePath, List docs, int requestId, String contentType) throws Exception {
  FusionSession fusionSession = getSession(hostAndPort, requestId);
  String postUrl = hostAndPort + pipelinePath;
  if (postUrl.indexOf("?") != -1) {
    postUrl += "&echo=false";
  } else {
    postUrl += "?echo=false";
  }

  HttpPost postRequest = new HttpPost(postUrl);
  ContentProducer cp = newContentProducer(contentType, docs);
  EntityTemplate et = new EntityTemplate(cp);
  et.setContentType(contentType);
  et.setContentEncoding(StandardCharsets.UTF_8.name());
  postRequest.setEntity(et);

  HttpEntity entity = null;
  CloseableHttpResponse response = null;
  try {

    HttpClientContext context = null;
    if (isKerberos) {
      response = httpClient.execute(postRequest);
    } else {
      context = HttpClientContext.create();
      if (cookieStore != null) {
        context.setCookieStore(cookieStore);
      }
      response = httpClient.execute(postRequest, context);
    }
    entity = response.getEntity();

    int statusCode = response.getStatusLine().getStatusCode();
    if (statusCode == 401) {
      // unauth'd - session probably expired? retry to establish
      log.warn("Unauthorized error (401) when trying to send request " + requestId +
              " to Fusion at " + hostAndPort + ", will re-try to establish session");

      // re-establish the session and re-try the request
      EntityUtils.consumeQuietly(entity);
      entity = null;
      response.close();

      synchronized (this) {
        fusionSession = resetSession(hostAndPort);
        if (fusionSession == null)
          throw new IllegalStateException("After re-establishing session when processing request " +
                  requestId + ", hostAndPort " + hostAndPort + " is no longer active! Try another hostAndPort.");
      }

      log.info("Going to re-try request " + requestId + " after session re-established with " + hostAndPort);
      if (isKerberos) {
        response = httpClient.execute(postRequest);
      } else {
        response = httpClient.execute(postRequest, context);
      }
      entity = response.getEntity();
      statusCode = response.getStatusLine().getStatusCode();
      if (statusCode == 200 || statusCode == 204) {
        log.info("Re-try request " + requestId + " after session timeout succeeded for: " + hostAndPort);
      } else {
        raiseFusionServerException(hostAndPort, entity, statusCode, response, requestId);
      }
    } else if (statusCode != 200 && statusCode != 204) {
      raiseFusionServerException(hostAndPort, entity, statusCode, response, requestId);
    } else {
      // OK!
      if (fusionSession != null && fusionSession.docsSentMeter != null)
        fusionSession.docsSentMeter.mark(docs.size());
    }
  } finally {
    EntityUtils.consumeQuietly(entity);
    if (response != null) response.close();
  }
}
 
开发者ID:lucidworks,项目名称:fusion-client-tools,代码行数:76,代码来源:FusionPipelineClient.java



注:本文中的org.apache.http.entity.ContentProducer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RatingCompat类代码示例发布时间:2022-05-21
下一篇:
Java VertxException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap