cz.vity.freerapid.plugins.webclient.utils
Class HttpUtils

java.lang.Object
  extended by cz.vity.freerapid.plugins.webclient.utils.HttpUtils

public final class HttpUtils
extends Object

Helpful utilities for parsing http headers

Author:
Ladislav Vitasek

Method Summary
static String getFileName(org.apache.commons.httpclient.HttpMethod method)
          Extracts file name from response header Content-Disposition Eg for Content-Disposition: =?
static String replaceInvalidCharsForFileSystem(String fileName, String replaceString)
          Replace invalid characters for file name on current file system with given one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFileName

public static String getFileName(org.apache.commons.httpclient.HttpMethod method)
Extracts file name from response header Content-Disposition Eg for Content-Disposition: =?UTF-8?attachment;filename="Two Peaks Personal Vehicle Manager 2005 3.2.zip";?= it returns Two Peaks Personal Vehicle Manager 2005 3.2.zip

Parameters:
method - executed HttpMethod with Content-Disposition header
Returns:
null if there was now header Content-Disposition or parsed file name

replaceInvalidCharsForFileSystem

public static String replaceInvalidCharsForFileSystem(String fileName,
                                                      String replaceString)
Replace invalid characters for file name on current file system with given one.
Usual use:
replaceInvalidCharsForFileSystem("diskFileName:", "_") returns diskFileName_ on Windows file system
For more information about illegal characters on file systems see: Forbidden Characters in Filenames

Parameters:
fileName - given file name
replaceString - usually a character that should be used for invalid characters
Returns:
string with replaced invalid characters