net.i2p.util

## Class EepHead

- java.lang.Object
- - net.i2p.util.EepGet
  - - net.i2p.util.EepHead

-     public class EepHead
      extends EepGet

  This is a quick hack to get a working EepHead, primarily for the following usage:

       EepHead foo = new EepHead(...);
       if (foo.fetch()) {
           String lastmod = foo.getLastModified();
           if (lastmod != null) {
               parse the string...
               ...
           }
       }

  Other use cases (command line, listeners, etc...) lightly- or un-tested. Note that this follows redirects! This may not be what you want or expect. Writing from scratch rather than extending EepGet would maybe have been less bloated memory-wise. This way gets us redirect handling, among other benefits.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class net.i2p.util.EepGet

      `EepGet.AUTH_MODE, EepGet.AuthState, EepGet.CLIStatusListener, EepGet.Gunzipper, EepGet.StatusListener`

  - ### Field Summary

    - ### Fields inherited from class net.i2p.util.EepGet

      `_aborted, _acceptRanges, _actualURL, _alreadyTransferred, _authState, _bytesRemaining, _bytesTransferred, _cacheControl, _contentEncoding, _contentLanguage, _contentType, _context, _cookie, _csp, _currentAttempt, _decompressException, _encodingChunked, _etag, _etagOrig, _expiryDate, _extraHeaders, _fetchHeaderTimeout, _fetchInactivityTimeout, _fetchTotalTimeout, _isGzippedResponse, _keepFetching, _lastModified, _lastModifiedOrig, _listeners, _log, _notModified, _numRetries, _out, _outputFile, _outputStream, _proxy, _proxyHost, _proxyIn, _proxyOut, _proxyPort, _redirectLocation, _redirects, _referrerPolicy, _responseCode, _responseText, _server, _shouldProxy, _shouldWriteErrorToOutput, _status, _transferEncoding, _transferFailed, _url, _vary, _xContentTypeOptions, _xframeOptions, _xPoweredBy, _xssProtection, CONNECT_TIMEOUT, INACTIVITY_TIMEOUT, MAX_COMPLETE_FAILS, USER_AGENT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `EepHead(I2PAppContext ctx, String proxyHost, int proxyPort, int numRetries, String url)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doFetch(SocketTimeout timeout)` This reads the response to a single fetch.
    `long` | `getContentLength()` We don't decrement the variable (unlike in EepGet), so this is valid
    `protected String` | `getRequest()`
    `static void` | `main(String[] args)` EepHead [-p 127.0.0.1:4444] [-n #retries] url This doesn't really do much since it doesn't register a listener.
    `protected boolean` | `shouldReadBody()` Should we read the body of the response?

    - ### Methods inherited from class net.i2p.util.EepGet

      `addAuthorization, addHeader, addStatusListener, fetch, fetch, fetch, getAcceptRanges, getCacheControl, getContentEncoding, getContentLanguage, getContentType, getCookie, getCSP, getEtag, getExpiryDate, getLastModified, getNotModified, getReferrerPolicy, getServer, getStatus, getStatusCode, getStatusText, getTransferEncoding, getVary, getXContentTypeOptions, getXframeOptions, getXPoweredBy, getXSSProtection, parseAuthArgs, readChunkLength, readHeaders, sendRequest, setPostData, setPostData, setPostData, setWriteErrorToOutput, stopFetching, suggestName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EepHead

          public EepHead(I2PAppContext ctx,
                         String proxyHost,
                         int proxyPort,
                         int numRetries,
                         String url)

  - ### Method Detail

    - #### doFetch

          protected void doFetch(SocketTimeout timeout)
                          throws IOException

      Description copied from class: `EepGet`
      This reads the response to a single fetch. Call after sendRequest()
      Overrides:
        `doFetch` in class `EepGet`
      Parameters:
        `timeout` - may be null as of 0.9.49
      Throws:
        `IOException`

    - #### getContentLength

          public long getContentLength()

      We don't decrement the variable (unlike in EepGet), so this is valid

    - #### getRequest

          protected String getRequest()
                               throws IOException

      Overrides:
        `getRequest` in class `EepGet`
      Throws:
        `IOException`

    - #### main

          public static void main(String[] args)

      EepHead [-p 127.0.0.1:4444] [-n #retries] url This doesn't really do much since it doesn't register a listener. EepGet doesn't have a method to store and return all the headers, so just print out the ones we have methods for. Turn on logging to use it for a decent test.

    - #### shouldReadBody

          protected boolean shouldReadBody()

      Should we read the body of the response?
      Overrides:
        `shouldReadBody` in class `EepGet`
      Returns:
        false always