org.das2.util.filesystem.HttpUtil

Utilities for HTTP protocol, such as a cache for the HEAD metadata.

HttpUtil( )


checkRedirect

checkRedirect( java.net.URLConnection urlConnection ) → URLConnection

check for 301, 302 or 303 redirects, and return a new connection in this case. This should be called immediately before the urlConnection.connect call, as this must connect to get the response code.

Parameters

urlConnection - if an HttpUrlConnection, check for 301 or 302; return connection otherwise.

Returns:

a connection, typically the same one as passed in.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


consumeStream

consumeStream( java.io.InputStream err ) → void

nice clients consume both the stderr and stdout coming from websites. This reads everything off of the stream and closes it. http://docs.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html suggests that you "do not abandon connection"

Parameters

err - the input stream

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


copyConnectProperties

copyConnectProperties( java.net.HttpURLConnection urlc, java.net.HttpURLConnection newConnection ) → void

copy over connection properties like Cookie and Accept-Encoding.

Parameters

urlc - a HttpURLConnection
newConnection - a HttpURLConnection

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getMetadata

getMetadata( java.net.URL url, java.util.Map props ) → Map

return the metadata about a URL. This will support http, https, and ftp, and will check for redirects. This will allow caching of head requests.

Parameters

url - ftp,https, or http URL
props - if non-null, may be a map containing cookie.

Returns:

the metadata

See Also:

WebProtocol#META_EXIST
WebProtocol#HTTP_RESPONSE_CODE


[search for examples] [view on GitHub] [view on old javadoc] [view source]