httpfactory.java
来自「很棒的web服务器源代码」· Java 代码 · 共 740 行 · 第 1/2 页
JAVA
740 行
*/ public static HttpCookieList parseCookieList(String strval) { HttpCookieList a = new HttpCookieList(); a.setString(strval); return a; } /** * Build credential informations. * @param scheme The scheme for that credentials. * @return An instance of HttpCredential. * @see HttpCredential */ public static HttpCredential makeCredential(String scheme) { return new HttpCredential(true, scheme); } /** * Build a credential object by parsing the given string. * @param strval The String to parse. * @return An HttpCredential instance. */ public static HttpCredential parseCredential(String strval) { HttpCredential a = new HttpCredential(); a.setString(strval); return a; } /** * Build an HTTP date object. * @param date The date, given in milliseconds since Java epoch. * @return An instance of HttpDate. * @see HttpDate */ public static HttpDate makeDate(long date) { return new HttpDate(true, date); } /** * Build an HTTP date object representing the current time. * @return An instance of HttpDate. * @see HttpDate */ public static HttpDate makeDate() { return new HttpDate(true, System.currentTimeMillis()); } /** * Build a date object by parsing the given string. * @param strval The String to parse. * @return An HttpDate instance. */ public static HttpDate parseDate(String strval) { HttpDate a = new HttpDate(); a.setString(strval); return a; } /** * Build an entity tag object. * @param isWeak Is this a weak entity tag. * @param tag The tag encoded as a String. * @return An instance of HttpEntityTag. * @see HttpEntityTag */ public static HttpEntityTag makeETag(boolean isWeak, String tag) { return new HttpEntityTag(true, isWeak, tag); } /** * Build an entity tag object by parsing the given string. * @param strval The String to parse. * @return An HttpEntityTag instance. */ public static HttpEntityTag parseETag(String strval) { HttpEntityTag a = new HttpEntityTag(); a.setString(strval); return a; } /** * Build an entity tag list. * @param tags A list of enetity tags, encoded as an array, or <strong> * null</strong> to create an empty list. * @return An instance of HttpEntityTagList. * @see HttpEntityTagList */ public static HttpEntityTagList makeETagList(HttpEntityTag tags[]) { return new HttpEntityTagList(tags); } /** * Build an entity tag list object by parsing the given string. * @param strval The String to parse. * @return An HttpEntityTagList instance. */ public static HttpEntityTagList parseEntityTagList(String strval) { HttpEntityTagList a = new HttpEntityTagList(); a.setString(strval); return a; } /** * Build a wrapper for an HTTP integer. * @param i The integer to wrap for HTTP transportation. * @return An instance of HttpInteger. * @see HttpInteger */ public static HttpInteger makeInteger(int i) { return new HttpInteger(true, i); } /** * Build an integer object by parsing the given string. * @param strval The String to parse. * @return An HttpInteger instance. */ public static HttpInteger parseInteger(String strval) { HttpInteger a = new HttpInteger(); a.setString(strval); return a; } /** * Build a wrapper for a MIME type suitable for HTTP transportation. * @param type The MIME type to wrap. * @return An instance of HttpMimeType. * @see HttpMimeType */ public static HttpMimeType makeMimeType(MimeType type) { return new HttpMimeType(true, type); } /** * Build an MIME type object by parsing the given string. * @param strval The String to parse. * @return An HttpMimeType instance. */ public static HttpMimeType parseMimeType(String strval) { HttpMimeType a = new HttpMimeType(); a.setString(strval); return a; } /** * Build an object representing an HTTP range. * @param unit The units in which that byte range is measured. * @param firstpos The first position of requested byte range. * @param lastpos The last position of requested byte range. * @return An instance of HttpRange. * @see HttpRange */ public static HttpRange makeRange(String unit, int firstpos, int lastpos) { return new HttpRange(true, unit, firstpos, lastpos); } /** * Build a range object by parsing the given string. * @param strval The String to parse. * @return An HttpRange instance. */ public static HttpRange parseRange(String strval) { HttpRange a = new HttpRange(); a.setString(strval); return a; } /** * Build a list of ranges. * @param ranges A list of ranges, encoded as an array, or <strong> * null</strong> to create an empty list. * @return An instance of HttprangeList. * @see HttpRangeList */ public static HttpRangeList makeRangeList(HttpRange ranges[]) { return new HttpRangeList(ranges); } /** * Build a list of ranges object by parsing the given string. * @param strval The String to parse. * @return An HttpRangeList instance. */ public static HttpRangeList parseRangeList(String strval) { HttpRangeList a = new HttpRangeList(); a.setString(strval); return a; } /** * Build a set cookie clause for the <code>Set-Cookie</code> header. * @param name The name of the cookie we are requesting to be set. * @param value It's value. * @return An instance of HttpSetCookie. * @see HttpSetCookie */ public static HttpSetCookie makeSetCookie(String name, String value) { return new HttpSetCookie(true, name, value); } /** * Build a list of set cookies commands. * @param setcookies A list of set cookie commands, encoded as an * array, or <strong>null</strong> to build an empty list. * @return An instance of HttpStCookieList. * @see HttpSetCookieList */ public static HttpSetCookieList makeSetCookieList(HttpSetCookie setcookies[]) { return new HttpSetCookieList(setcookies); } /** * Build a list of set cookies object by parsing the given string. * @param strval The String to parse. * @return An HttpSetCookieList instance. */ public static HttpSetCookieList parseSetCookieList(String strval) { HttpSetCookieList a = new HttpSetCookieList(); a.setString(strval); return a; } /** * Build a wrapper for a String, for HTTP transportation. * @param str The String (or <em>token</em>) to wrap. * @return An instance of HttpString. * @see HttpString */ public static HttpString makeString(String str) { return new HttpString(true, str); } /** * Build a String object by parsing the given string. * @param strval The String to parse. * @return An HttpString instance. */ public static HttpString parseString(String strval) { HttpString a = new HttpString(); a.setString(strval); return a; } /** * Build a list of strings. * @param list The list of strings, encoded as an array, or <strong>null * </strong> to create an empty list. * @return An instance of HttpTokenList. * @see HttpTokenList */ public static HttpTokenList makeStringList(String list[]) { return new HttpTokenList(list); } /** * Build a list of one string. * @param item The item to be added to the list. * @return An instance of HttpTokenList. * @see HttpTokenList */ public static HttpTokenList makeStringList(String item) { String list[] = new String[1]; list[0] = item; return new HttpTokenList(list); } /** * Build a list of string object by parsing the given string. * @param strval The String to parse. * @return An HttpTokenList instance. */ public static HttpTokenList parseTokenList(String strval) { HttpTokenList a = new HttpTokenList(); a.setString(strval); return a; } /** * Build an HTTP Warning object. * @param status The warning status code. * @param agent The agent generating that warning. * @param text The text for the warning. * @return An instance of HttpWarning. * @see HttpWarning */ public static HttpWarning makeWarning(int status , String agent , String text) { return new HttpWarning(true, status, agent, text); } /** * Build an HTTP Warning object. * @param status The warning status code. * @return An instance of HttpWarning. * @see HttpWarning */ public static HttpWarning makeWarning(int status) { return new HttpWarning(true, status, null, null); } /** * Build a warning object by parsing the given string. * @param strval The String to parse. * @return An HttpWarning instance. */ public static HttpWarning parseWarning(String strval) { HttpWarning a = new HttpWarning(); a.setString(strval); return a; } /** * Build a list of warnings for the <code>Warning</code> header. * @param warnings A list of warning encoded as an array, or <strong> * null</strong> to get an empty list. * @return An instance of HttpWarningList. * @see HttpWarningList */ public static HttpWarningList makeWarningList(HttpWarning warnings[]) { return new HttpWarningList(warnings); } /** * Build a list of warnings object by parsing the given string. * @param strval The String to parse. * @return An HttpWarningList instance. */ public static HttpWarningList parseWarningList(String strval) { HttpWarningList a = new HttpWarningList(); a.setString(strval); return a; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?