Package org.globus.io.streams
Class HTTPOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.globus.io.streams.GlobusOutputStream
-
- org.globus.io.streams.HTTPOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
- Direct Known Subclasses:
GassOutputStream
public class HTTPOutputStream extends GlobusOutputStream
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanappendprivate static byte[]CRLFprivate static intDEFAULT_TIMEprotected java.io.InputStreaminprivate static org.apache.commons.logging.Logloggerprotected java.io.OutputStreamoutputprotected longsizeprotected java.net.Socketsocket
-
Constructor Summary
Constructors Modifier Constructor Description protectedHTTPOutputStream()Private constructor used by subclasses.HTTPOutputStream(java.lang.String host, int port, java.lang.String file, long length, boolean append)Opens HTTP output stream (unsecure)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Aborts transfer.private voidcheckForReply()voidclose()private voidcloseSocket()private voidfinish()voidflush()private voidinit(java.lang.String host, int port, java.lang.String file, long length, boolean append)protected voidput(java.lang.String host, java.lang.String file, long length, int waittime)private voidsleep(int time)voidwrite(byte[] msg)voidwrite(byte[] msg, int from, int length)voidwrite(int b)
-
-
-
Field Detail
-
logger
private static org.apache.commons.logging.Log logger
-
CRLF
private static final byte[] CRLF
-
DEFAULT_TIME
private static final int DEFAULT_TIME
- See Also:
- Constant Field Values
-
output
protected java.io.OutputStream output
-
in
protected java.io.InputStream in
-
socket
protected java.net.Socket socket
-
size
protected long size
-
append
protected boolean append
-
-
Constructor Detail
-
HTTPOutputStream
protected HTTPOutputStream()
Private constructor used by subclasses.
-
HTTPOutputStream
public HTTPOutputStream(java.lang.String host, int port, java.lang.String file, long length, boolean append) throws GassException, java.io.IOExceptionOpens HTTP output stream (unsecure)- Parameters:
host- host name of the HTTP server.port- port number of the HTTP server.file- name of the file on the remote side.length- total size of the data to be transfered. Use -1 if unknown. The data then will be transfered in chunks.append- if true, append data to existing file. Otherwise, the file will be overwritten.- Throws:
GassExceptionjava.io.IOException
-
-
Method Detail
-
init
private void init(java.lang.String host, int port, java.lang.String file, long length, boolean append) throws GassException, java.io.IOException- Throws:
GassExceptionjava.io.IOException
-
sleep
private void sleep(int time)
-
put
protected void put(java.lang.String host, java.lang.String file, long length, int waittime) throws java.io.IOException- Throws:
java.io.IOException
-
checkForReply
private void checkForReply() throws java.io.IOException- Throws:
java.io.IOException
-
finish
private void finish() throws java.io.IOException- Throws:
java.io.IOException
-
closeSocket
private void closeSocket()
-
abort
public void abort()
Description copied from class:GlobusOutputStreamAborts transfer. Usually makes sure to release all resources (sockets, file descriptors)
Does nothing by default.- Overrides:
abortin classGlobusOutputStream
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] msg) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] msg, int from, int length) throws java.io.IOException- Overrides:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException- Overrides:
writein classGlobusOutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
-