All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.horizon.ning.internal.SnappyHttpResponseWrapper Maven / Gradle / Ivy

There is a newer version: 0.3.0
Show newest version
package com.hubspot.horizon.ning.internal;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
import com.hubspot.horizon.Headers;
import com.hubspot.horizon.HttpRequest;
import com.hubspot.horizon.internal.AbstractHttpResponse;
import java.io.IOException;
import java.io.InputStream;
import org.xerial.snappy.SnappyInputStream;

public class SnappyHttpResponseWrapper extends AbstractHttpResponse {

  private final AbstractHttpResponse delegate;
  private final InputStream wrapped;

  public SnappyHttpResponseWrapper(AbstractHttpResponse delegate) throws IOException {
    this.delegate = Preconditions.checkNotNull(delegate);
    this.wrapped = new SnappyInputStream(delegate.getAsInputStream());
  }

  @Override
  public ObjectMapper getObjectMapper() {
    return delegate.getObjectMapper();
  }

  @Override
  public HttpRequest getRequest() {
    return delegate.getRequest();
  }

  @Override
  public int getStatusCode() {
    return delegate.getStatusCode();
  }

  @Override
  public Headers getHeaders() {
    return delegate.getHeaders();
  }

  @Override
  public InputStream getAsInputStream() {
    return wrapped;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy