com.ibm.wbi.protocol.http.beans
Class PutGenerator
com.ibm.wbi.Meg
|
+--com.ibm.wbi.Generator
|
+--com.ibm.wbi.protocol.http.HttpGenerator
|
+--com.ibm.wbi.protocol.http.beans.PutGenerator
- public class PutGenerator
- extends HttpGenerator
A Generator that handles HTTP 'PUT' requests and stores the results in a
file on the local file system.
It has three properties: Directory, UrlPrefix, and CreateNeededDirectories.
- Directory
- Specifies the directory in the local file system where files are to be stored.
- UrlPrefix
- specifies a path prefix that will be expected to be part of the requested URL
that will be ignored. For example, if the Directory is "c:\putfiles" and the
UrlPrefix is "home/data" and the 'PUT' URL is: "http://myserver/home/data/foo/a.html"
then the Generator will store the file "c:\putfiles\foo\a.html".
- CreateNeededDirectories
- a boolean that specifies whether subdirectories should be automatically created
if a PUT request attempts to store a file in a non-existant child of Directory.
If false and the subdirectory does not exist, a 400 error is returned to the
browser.
The PUT request must contain a content-length header entry. It may also
optionally contain a content-range header entry. Use of content-range
allows a client to PUT portions of a file in separate PUT requests.
Upon successful completion of the PUT operation, the Generator sends a brief message
back to the browser, with an HTTP response code of 200. Upon an error condition,
the Generator sends a brief explanation with an HTTP response code of 400. The
possible error conditions are:
- the UrlPrefix does not match the beginning of the requested URL path;
- the request does not contain a content-length header entry;
- fewer bytes were written than content-length specified (this can only
happen if the client broke the connection, so the error message will never be
received; and
- an IOException occurred during the transaction.
|
Field Summary |
static java.lang.String |
COPYRIGHT
IBM copyright information |
| Methods inherited from class com.ibm.wbi.protocol.http.HttpGenerator |
add, addCookie, getContentType, getHttpResponse, getHttpResponseString, getResponseCode, getResponseText, isCache, produceHeader, set, setCache, setContentLength, setContentType, setResponseCode, setResponseText, setServer, writeHeader |
| Methods inherited from class com.ibm.wbi.Meg |
forwardRequest, getCondition, getEnabled, getMegProperty, getMegProperty, getMegPropertyKeys, getName, getPlugin, getPriority, getSystemContext, initialize, initialize, isEnabled, isMegApplicable, loadMegResources, run, setCondition, setEnabled, setMegProperty, setName, setPriority, setSystemContext, setup, setup, setup, setup |
COPYRIGHT
public static final java.lang.String COPYRIGHT
- IBM copyright information
PutGenerator
public PutGenerator()
- The default constructor. Directory defaults to "../data";
UrlPrefix defaults to null; CreateNeededDirectories defaults
to true.
setDirectory
public void setDirectory(java.lang.String dir)
- Set the Directory property. This is the directory in which files will
be stored. For example, "C:\data"
- Parameters:
dir - The Directory.
getDirectory
public java.lang.String getDirectory()
- Access the Directory property.
- Returns:
- The Directory
setCreateNeededDirectories
public void setCreateNeededDirectories(boolean cnd)
- Set the CreateNeededDirectories property.
This property determines whether a PUT request is allowed to specify
a non-existent directory, in which case it will automatically be
created. If this property is false, such a request will generate
an error.
- Parameters:
cnd - Create directories?
isCreateNeededDirectories
public boolean isCreateNeededDirectories()
- Access the CreateNeededDirectories property.
- Returns:
- Create directories?
setUrlPrefix
public void setUrlPrefix(java.lang.String up)
- Set the UrlPrefix property. This property specifies what leading
characters of the URL path should be ignored when determining where
to store the file in the local file system.
For example, if urlPrefix=="/wbi" and directory=="../data" and the URL
Path="/wbi/foo/bar.baz" then the file "bar.baz" will be stored in the
"../data/foo" directory.
- Parameters:
up - The UrlPrefix
getUrlPrefix
public java.lang.String getUrlPrefix()
- Access the UrlPrefix property.
- Returns:
- The UrlPrefix
handleRequest
public void handleRequest(RequestEvent e)
throws RequestRejectedException,
java.io.IOException
- The method used by WBI to handle the PUT request.
- Overrides:
handleRequest in class HttpGenerator
- Parameters:
e - The request event.- Throws:
RequestRejectedException - To reject request.