org.apache.commons.httpclient.util.ParameterParser Java Examples
The following examples show how to use
org.apache.commons.httpclient.util.ParameterParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthChallengeParser.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Extracts a map of challenge parameters from an authentication challenge. * Keys in the map are lower-cased * * @param challengeStr the authentication challenge string * @return a map of authentication challenge parameters * @throws MalformedChallengeException when the authentication challenge string * is malformed * * @since 2.0beta1 */ public static Map extractParams(final String challengeStr) throws MalformedChallengeException { if (challengeStr == null) { throw new IllegalArgumentException("Challenge may not be null"); } int idx = challengeStr.indexOf(' '); if (idx == -1) { throw new MalformedChallengeException("Invalid challenge: " + challengeStr); } Map map = new HashMap(); ParameterParser parser = new ParameterParser(); List params = parser.parse( challengeStr.substring(idx + 1, challengeStr.length()), ','); for (int i = 0; i < params.size(); i++) { NameValuePair param = (NameValuePair) params.get(i); map.put(param.getName().toLowerCase(), param.getValue()); } return map; }
Example #2
Source File: HeaderElement.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Constructor with array of characters. * * @param chars the array of characters * @param offset - the initial offset. * @param length - the length. * * @since 3.0 */ public HeaderElement(char[] chars, int offset, int length) { this(); if (chars == null) { return; } ParameterParser parser = new ParameterParser(); List params = parser.parse(chars, offset, length, ';'); if (params.size() > 0) { NameValuePair element = (NameValuePair) params.remove(0); setName(element.getName()); setValue(element.getValue()); if (params.size() > 0) { this.parameters = (NameValuePair[]) params.toArray(new NameValuePair[params.size()]); } } }
Example #3
Source File: RestUtilities.java From Knowage-Server with GNU Affero General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public static List<NameValuePair> getAddressPairs(String address) { try { String query = URIUtil.getQuery(address); List<NameValuePair> params = new ParameterParser().parse(query, '&'); List<NameValuePair> res = new ArrayList<NameValuePair>(); for (NameValuePair nvp : params) { res.add(new NameValuePair(URIUtil.decode(nvp.getName(), DEFAULT_CHARSET), URIUtil.decode(nvp.getValue(), DEFAULT_CHARSET))); } return res; } catch (URIException e) { throw new SpagoBIRuntimeException(e); } }