org.apache.http.HttpResponseFactory Java Examples

The following examples show how to use org.apache.http.HttpResponseFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtendedHttpClientBuilder.java    From lavaplayer with Apache License 2.0 5 votes vote down vote up
public GarbageAllergicHttpResponseParser(
    SessionInputBuffer buffer,
    LineParser lineParser,
    HttpResponseFactory responseFactory,
    MessageConstraints constraints
) {
  super(buffer, lineParser, responseFactory, constraints);
}
 
Example #2
Source File: AsyncRequestWrapperTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private AsyncRequestWrapperImpl createAsyncRequestWrapperImplWithRetryAfter(int retryAfter)
    throws IOException, URISyntaxException {

  HttpClient httpClient = mock(HttpClient.class);
  ODataClient oDataClient = mock(ODataClient.class);
  Configuration configuration = mock(Configuration.class);
  HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
  HttpUriRequestFactory httpUriRequestFactory = mock(HttpUriRequestFactory.class);
  HttpUriRequest httpUriRequest = mock(HttpUriRequest.class);

  when(oDataClient.getConfiguration()).thenReturn(configuration);
  when(configuration.getHttpClientFactory()).thenReturn(httpClientFactory);
  when(configuration.getHttpUriRequestFactory()).thenReturn(httpUriRequestFactory);
  when(httpClientFactory.create(any(), any())).thenReturn(httpClient);
  when(httpUriRequestFactory.create(any(), any())).thenReturn(httpUriRequest);

  HttpResponseFactory factory = new DefaultHttpResponseFactory();
  HttpResponse firstResponse = factory.newHttpResponse(
      new BasicStatusLine(HttpVersion.HTTP_1_1, 202, null), null);
  firstResponse.addHeader(HttpHeader.LOCATION, "http://localhost/monitor");
  firstResponse.addHeader(HttpHeader.RETRY_AFTER, String.valueOf(retryAfter));
  when(httpClient.execute(any(HttpUriRequest.class))).thenReturn(firstResponse);

  AbstractODataRequest oDataRequest = mock(AbstractODataRequest.class);
  ODataResponse oDataResponse = mock(ODataResponse.class);
  when(oDataRequest.getResponseTemplate()).thenReturn(oDataResponse);
  when(oDataRequest.getURI()).thenReturn(new URI("http://localhost/path"));
  when(oDataResponse.initFromHttpResponse(any(HttpResponse.class))).thenReturn(null);

  return new AsyncRequestWrapperImpl(oDataClient, oDataRequest);
}
 
Example #3
Source File: AsyncRequestWrapperTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private AsyncResponseWrapperImpl createAsyncRequestWrapperImplWithLocation(String target, String location)
    throws IOException, URISyntaxException {

  HttpClient httpClient = mock(HttpClient.class);
  ODataClient oDataClient = mock(ODataClient.class);
  Configuration configuration = mock(Configuration.class);
  HttpClientFactory httpClientFactory = mock(HttpClientFactory.class);
  HttpUriRequestFactory httpUriRequestFactory = mock(HttpUriRequestFactory.class);
  HttpUriRequest httpUriRequest = mock(HttpUriRequest.class);

  when(oDataClient.getConfiguration()).thenReturn(configuration);
  when(configuration.getHttpClientFactory()).thenReturn(httpClientFactory);
  when(configuration.getHttpUriRequestFactory()).thenReturn(httpUriRequestFactory);
  when(httpClientFactory.create(any(), any())).thenReturn(httpClient);
  when(httpUriRequestFactory.create(any(), any())).thenReturn(httpUriRequest);

  HttpResponseFactory factory = new DefaultHttpResponseFactory();
  HttpResponse firstResponse = factory.newHttpResponse(
      new BasicStatusLine(HttpVersion.HTTP_1_1, 202, null), null);
  firstResponse.addHeader(HttpHeader.LOCATION, location);
  when(httpClient.execute(any(HttpUriRequest.class))).thenReturn(firstResponse);

  ODataResponse oDataResponse = mock(ODataResponse.class);
  when(oDataResponse.initFromHttpResponse(any(HttpResponse.class))).thenReturn(null);

  AbstractODataRequest oDataRequest = mock(AbstractODataRequest.class);
  when(oDataRequest.getURI()).thenReturn(new URI(target));
  when(oDataRequest.getResponseTemplate()).thenReturn(oDataResponse);

  AsyncRequestWrapperImpl req = new AsyncRequestWrapperImpl(oDataClient, oDataRequest);
  AsyncResponseWrapper wrappedResponse = req.execute();
  assertTrue(wrappedResponse instanceof AsyncResponseWrapperImpl);
  return (AsyncResponseWrapperImpl) wrappedResponse;
}
 
Example #4
Source File: CustomConnectionsHttpClientFactory.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
protected HttpMessageParser<HttpResponse> createResponseParser(
        final SessionInputBuffer buffer,
        final HttpResponseFactory responseFactory,
        final HttpParams params) {

  return new DefaultHttpResponseParser(
          buffer,
          new MyLineParser(),
          responseFactory,
          params);
}
 
Example #5
Source File: HttpServerConnectionUpnpStream.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public UpnpHttpService(HttpProcessor processor, ConnectionReuseStrategy reuse, HttpResponseFactory responseFactory) {
    super(processor, reuse, responseFactory);
}
 
Example #6
Source File: IheHttpFactory.java    From openxds with Apache License 2.0 4 votes vote down vote up
public HttpResponseFactory newResponseFactory() {
    return new DefaultHttpResponseFactory();
}
 
Example #7
Source File: HttpUtils.java    From MediaPlayerProxy with Apache License 2.0 4 votes vote down vote up
@Override
protected HttpMessageParser createResponseParser(final SessionInputBuffer buffer,
		final HttpResponseFactory responseFactory, final HttpParams params) {
	return new DefaultResponseParser(buffer, new IcyLineParser(), responseFactory, params);
}
 
Example #8
Source File: HttpServerConnectionUpnpStream.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public UpnpHttpService(HttpProcessor processor, ConnectionReuseStrategy reuse, HttpResponseFactory responseFactory) {
    super(processor, reuse, responseFactory);
}
 
Example #9
Source File: DropboxFileDownloaderTest.java    From endpoints-codelab-android with GNU General Public License v3.0 4 votes vote down vote up
private DropboxServerException notFoundException() {
    HttpResponseFactory factory = new DefaultHttpResponseFactory();
    HttpResponse response = factory.newHttpResponse(new BasicStatusLine(
            HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_FOUND, null), null);
    return new DropboxServerException(response);
}
 
Example #10
Source File: DropboxFileUploaderTest.java    From endpoints-codelab-android with GNU General Public License v3.0 4 votes vote down vote up
private DropboxServerException notFoundException() {
    HttpResponseFactory factory = new DefaultHttpResponseFactory();
    HttpResponse response = factory.newHttpResponse(new BasicStatusLine(
            HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_FOUND, null), null);
    return new DropboxServerException(response);
}