Tabnine Logo
HttpUtils$Worker
Code IndexAdd Tabnine to your IDE (free)

How to use
HttpUtils$Worker
in
org.deegree.commons.utils.net

Best Java code snippets using org.deegree.commons.utils.net.HttpUtils$Worker (Showing top 11 results out of 315)

origin: deegree/deegree3

HttpEntity entity = resp.getEntity();
LOG.debug( "Received response with content type {}", entity.getContentType() );
return new Pair<T, HttpResponse>( worker.work( entity.getContent() ), resp );
origin: deegree/deegree3

  res.first = IMAGE.work( conn.getInputStream() );
} else if ( conn.getContentType() != null
      && conn.getContentType().startsWith( "application/vnd.ogc.se_xml" ) ) {
  res.second = XmlHttpUtils.XML.work( conn.getInputStream() ).toString();
} else { // try and find out the hard way
  res.first = IMAGE.work( conn.getInputStream() );
  if ( res.first == null ) {
    conn = theUrl.openConnection();
    res.second = XmlHttpUtils.XML.work( conn.getInputStream() ).toString();
origin: deegree/deegree3

  return worker.work( u.getURL().openStream() );
return worker.work( client.execute( get ).getEntity().getContent() );
origin: deegree/deegree3

return worker.work( entity.getContent() );
origin: deegree/deegree3

return new Pair<T, HttpResponse>( worker.work( response.getEntity().getContent() ), response );
origin: deegree/deegree3

return worker.work( client.execute( post ).getEntity().getContent() );
origin: deegree/deegree3

public static <T> Pair<T, HttpResponse> getFullResponse( Worker<T> worker, String url, Map<String, String> headers,
                             String user, String pass, final int readTimeout )
            throws IOException {
  DURL u = new DURL( url );
  if ( !u.valid() ) {
    return null;
  }
  DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u );
  client.setKeepAliveStrategy( new DefaultConnectionKeepAliveStrategy() {
    @Override
    public long getKeepAliveDuration( HttpResponse response, HttpContext context ) {
      long keepAlive = super.getKeepAliveDuration( response, context );
      if ( keepAlive == -1 ) {
        keepAlive = readTimeout * 1000;
      }
      return keepAlive;
    }
  } );
  if ( user != null && pass != null ) {
    authenticate( client, user, pass, u );
  }
  HttpGet get = new HttpGet( url );
  if ( headers != null ) {
    for ( String key : headers.keySet() ) {
      get.addHeader( key, headers.get( key ) );
    }
  }
  HttpResponse response = client.execute( get );
  return new Pair<T, HttpResponse>( worker.work( response.getEntity().getContent() ), response );
}
origin: deegree/deegree3

/**
 * Performs an HTTP-Get request and provides typed access to the response.
 * 
 * @param <T>
 * @param worker
 * @param url
 * @param postBody
 * @param headers
 *            may be null
 * @return some object from the url
 * @throws IOException
 */
public static <T> T post( Worker<T> worker, String url, InputStream postBody, Map<String, String> headers )
            throws IOException {
  DURL u = new DURL( url );
  DefaultHttpClient client = enableProxyUsage( new DefaultHttpClient(), u );
  HttpPost post = new HttpPost( url );
  post.setEntity( new InputStreamEntity( postBody, -1 ) );
  if ( headers != null ) {
    for ( String key : headers.keySet() ) {
      post.addHeader( key, headers.get( key ) );
    }
  }
  return worker.work( client.execute( post ).getEntity().getContent() );
}
origin: deegree/deegree3

/**
 * Returns the tile as an image.
 * 
 * @return image, never <code>null</code>
 * @throws IOException
 * @throws XMLStreamException
 * @throws OWSExceptionReport
 */
public BufferedImage getAsImage()
            throws IOException, OWSExceptionReport, XMLStreamException {
  rawResponse.assertNoXmlContentTypeAndExceptionReport();
  BufferedImage image = null;
  try {
    InputStream is = rawResponse.getAsBinaryStream();
    image = HttpUtils.IMAGE.work( is );
  } finally {
    rawResponse.close();
  }
  return image;
}
origin: deegree/deegree3

  /**
   * 
   * @param url
   * @return a {@link Pair} of {@link BufferedImage} and {@link String}. In case the WPVS returns an image the former
   *         will be used, otherwise an XML response ( as a String ) will be returned in the second value.
   * @throws IOException
   */
  public synchronized Pair<BufferedImage, String> getView( URL url )
              throws IOException {
    Pair<BufferedImage, String> res = new Pair<BufferedImage, String>();
    InputStream inStream = url.openStream();
    res.first = IMAGE.work( inStream );
    // rb: the following will never happen (I guess)
    if ( res.first == null ) {
      res.second = XmlHttpUtils.XML.work( url.openStream() ).toString();
    }
    inStream.close();

    return res;
  }
}
origin: deegree/deegree3

/**
 * @param <T>
 * @param worker
 * @param url
 *            must be valid
 * @return some object from the url
 * @throws IOException
 */
public static <T> T retrieve( Worker<T> worker, DURL url )
            throws IOException {
  return worker.work( url.openStream() );
}
org.deegree.commons.utils.netHttpUtils$Worker

Javadoc

Worker is used to specify how to return the stream from the remote location.

Most used methods

  • work

Popular in Java

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • compareTo (BigDecimal)
  • scheduleAtFixedRate (Timer)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now