/** * This can be used to add a HTTP message header to this object. * The name and value of the HTTP message header will be used to * create a HTTP message header object which can be retrieved using * the <code>getInteger</code> in combination with the get methods. * * @param name the name of the HTTP message header to be added * @param value the value the HTTP message header will have */ public void addInteger(String name, int value) { addValue(name, String.valueOf(value)); }
/** * This can be used to get the values of HTTP message headers * that have the specified name. This is a convenience method that * will present that values as tokens extracted from the header. * This has obvious performance benefits as it avoids having to * deal with <code>substring</code> and <code>trim</code> calls. * <p> * The tokens returned by this method are ordered according to * there HTTP quality values, or "q" values, see RFC 2616 section * 3.9. This also strips out the quality parameter from tokens * returned. So "image/html; q=0.9" results in "image/html". If * there are no "q" values present then order is by appearance. * <p> * The result from this is either the trimmed header value, that * is, the header value with no leading or trailing whitespace * or an array of trimmed tokens ordered with the most preferred * in the lower indexes, so index 0 is has highest preference. * * @param name the name of the headers that are to be retrieved * * @return ordered list of tokens extracted from the header(s) */ public List<String> getValues(String name) { return getValues(getAll(name)); }
/** * This is used to acquire a cookie using the name of that cookie. * If the cookie exists within the HTTP header then it is returned * as a <code>Cookie</code> object. Otherwise this method will * return null. Each cookie object will contain the name, value * and path of the cookie as well as the optional domain part. * * @param name this is the name of the cookie object to acquire * * @return this returns a cookie object from the header or null */ public Cookie getCookie(String name) { return header.getCookie(name); }
/** * This can be used to get the value of the first message header * that has the specified name. This will return the full string * representing the named header value. If the named header does * not exist then this will return a null value. * * @param name the HTTP message header to get the value from * * @return this returns the value that the HTTP message header */ public String getValue(String name) { return getValue(name, 0); }
/** * This can be used to add a HTTP message header to this object. * The name and value of the HTTP message header will be used to * create a HTTP message header object which can be retrieved using * the <code>getValue</code> in combination with the get methods. * * @param name the name of the HTTP message header to be added * @param value the value the HTTP message header will have */ public void addValue(String name, String value) { List<String> list = getAll(name); if(value != null) { list.add(value); } }
/** * This method is used to get a <code>List</code> of the names * for the headers. This will provide the original names for the * HTTP headers for the message. Modifications to the provided * list will not affect the header, the list is a simple copy. * * @return this returns a list of the names within the header */ public List<String> getNames() { return header.getNames(); }
/** * This can be used to get the integer of the first message header * that has the specified name. This is a convenience method that * avoids having to deal with parsing the value of the requested * HTTP message header. This returns -1 if theres no HTTP header * value for the specified name. * * @param name the HTTP message header to get the value from * * @return this returns the date as a long from the header value */ public int getInteger(String name) { return header.getInteger(name); }
/** * This can be used to get the date of the first message header * that has the specified name. This is a convenience method that * avoids having to deal with parsing the value of the requested * HTTP message header. This returns -1 if theres no HTTP header * value for the specified name. * * @param name the HTTP message header to get the value from * * @return this returns the date as a long from the header value */ public long getDate(String name) { return header.getDate(name); }
/** * This is used to acquire all cookies that were sent in the header. * If any cookies exists within the HTTP header they are returned * as <code>Cookie</code> objects. Otherwise this method will an * empty list. Each cookie object will contain the name, value and * path of the cookie as well as the optional domain part. * * @return this returns all cookie objects from the HTTP header */ public List<Cookie> getCookies() { return header.getCookies(); } }
/** * Constructor for the <code>SegmentConsumer</code> object. This * is used to create a segment consumer used to consume and parse * a HTTP message header. This delegates parsing of headers if * they represent special headers, like content type or cookies. * * @param limit this is the length limit for a HTTP header */ public SegmentConsumer(int limit) { this.language = new LanguageParser(); this.cookies = new CookieParser(); this.header = new MessageHeader(); this.limit = limit; this.length = -1; }
/** * This can be used to get the values of HTTP message headers * that have the specified name. This is a convenience method that * will present that values as tokens extracted from the header. * This has obvious performance benefits as it avoids having to * deal with <code>substring</code> and <code>trim</code> calls. * <p> * The tokens returned by this method are ordered according to * there HTTP quality values, or "q" values, see RFC 2616 section * 3.9. This also strips out the quality parameter from tokens * returned. So "image/html; q=0.9" results in "image/html". If * there are no "q" values present then order is by appearance. * <p> * The result from this is either the trimmed header value, that * is, the header value with no leading or trailing whitespace * or an array of trimmed tokens ordered with the most preferred * in the lower indexes, so index 0 is has highest preference. * * @param name the name of the headers that are to be retrieved * * @return ordered array of tokens extracted from the header(s) */ public List<String> getValues(String name) { return header.getValues(name); }
/** * This can be used to get the value of the first message header * that has the specified name. This will return the full string * representing the named header value. If the named header does * not exist then this will return a null value. * * @param name the HTTP message header to get the value from * * @return this returns the value that the HTTP message header */ public String getValue(String name) { return getValue(name, 0); }
/** * This can be used to add a HTTP message header to this object. * The name and value of the HTTP message header will be used to * create a HTTP message header object which can be retrieved using * the <code>getValue</code> in combination with the get methods. * * @param name the name of the HTTP message header to be added * @param value the value the HTTP message header will have */ public void addValue(String name, String value) { List<String> list = getAll(name); if(value != null) { list.add(value); } }
/** * This method is used to get a <code>List</code> of the names * for the headers. This will provide the original names for the * HTTP headers for the message. Modifications to the provided * list will not affect the header, the list is a simple copy. * * @return this returns a list of the names within the header */ public List<String> getNames() { return header.getNames(); }
/** * This can be used to get the integer of the first message header * that has the specified name. This is a convenience method that * avoids having to deal with parsing the value of the requested * HTTP message header. This returns -1 if theres no HTTP header * value for the specified name. * * @param name the HTTP message header to get the value from * * @return this returns the date as a long from the header value */ public int getInteger(String name) { return header.getInteger(name); }
/** * This can be used to get the date of the first message header * that has the specified name. This is a convenience method that * avoids having to deal with parsing the value of the requested * HTTP message header. This returns -1 if theres no HTTP header * value for the specified name. * * @param name the HTTP message header to get the value from * * @return this returns the date as a long from the header value */ public long getDate(String name) { return header.getDate(name); }
/** * This is used to acquire all cookies that were sent in the header. * If any cookies exists within the HTTP header they are returned * as <code>Cookie</code> objects. Otherwise this method will an * empty list. Each cookie object will contain the name, value and * path of the cookie as well as the optional domain part. * * @return this returns all cookie objects from the HTTP header */ public List<Cookie> getCookies() { return header.getCookies(); } }
/** * Constructor for the <code>SegmentConsumer</code> object. This * is used to create a segment consumer used to consume and parse * a HTTP message header. This delegates parsing of headers if * they represent special headers, like content type or cookies. * * @param limit this is the length limit for a HTTP header */ public SegmentConsumer(int limit) { this.language = new LanguageParser(); this.cookies = new CookieParser(); this.header = new MessageHeader(); this.limit = limit; this.length = -1; }
/** * This can be used to get the values of HTTP message headers * that have the specified name. This is a convenience method that * will present that values as tokens extracted from the header. * This has obvious performance benefits as it avoids having to * deal with <code>substring</code> and <code>trim</code> calls. * <p> * The tokens returned by this method are ordered according to * there HTTP quality values, or "q" values, see RFC 2616 section * 3.9. This also strips out the quality parameter from tokens * returned. So "image/html; q=0.9" results in "image/html". If * there are no "q" values present then order is by appearance. * <p> * The result from this is either the trimmed header value, that * is, the header value with no leading or trailing whitespace * or an array of trimmed tokens ordered with the most preferred * in the lower indexes, so index 0 is has highest preference. * * @param name the name of the headers that are to be retrieved * * @return ordered array of tokens extracted from the header(s) */ public List<String> getValues(String name) { return header.getValues(name); }
/** * This can be used to get the value of the first message header * that has the specified name. This will return the full string * representing the named header value. If the named header does * not exist then this will return a null value. * * @param name the HTTP message header to get the value from * * @return this returns the value that the HTTP message header */ public String getValue(String name) { return getValue(name, 0); }