public static Float getQuality(String value) { if (value == null) return __zero; int qe = value.indexOf(";"); if (qe++ < 0 || qe == value.length()) return __one; if (value.charAt(qe++) == 'q') { qe++; Map.Entry entry = __qualities.getEntry(value, qe, value.length() - qe); if (entry != null) return (Float) entry.getValue(); } HashMap params = new HashMap(3); valueParameters(value, params); String qs = (String) params.get("q"); Float q = (Float) __qualities.get(qs); if (q == null) { try { q = new Float(qs); } catch (Exception e) { q = __one; } } return q; }
@Override public Enumeration<Locale> getLocales() { Enumeration<String> enm = _fields.getValues(HttpHeader.ACCEPT_LANGUAGE.toString(),HttpFields.__separators); // handle no locale if (enm == null || !enm.hasMoreElements()) return Collections.enumeration(__defaultLocale); // sort the list in quality order List<String> acceptLanguage = HttpFields.qualityList(enm); if (acceptLanguage.size() == 0) return Collections.enumeration(__defaultLocale); List<Locale> langs = new ArrayList<>(); // convert to locals for (String language : acceptLanguage) { language = HttpFields.valueParameters(language, null); String country = ""; int dash = language.indexOf('-'); if (dash > -1) { country = language.substring(dash + 1).trim(); language = language.substring(0, dash).trim(); } langs.add(new Locale(language, country)); } if (langs.size() == 0) return Collections.enumeration(__defaultLocale); return Collections.enumeration(langs); }
valueParameters(value, params); String qs = params.get("q"); if (qs==null)
public Locale getLocale() { Enumeration enm = _connection.getRequestFields().getValues(HttpHeaders.ACCEPT_LANGUAGE,HttpFields.__separators); // handle no locale if (enm == null || !enm.hasMoreElements()) return Locale.getDefault(); // sort the list in quality order List acceptLanguage = HttpFields.qualityList(enm); if (acceptLanguage.size() == 0) return Locale.getDefault(); int size = acceptLanguage.size(); if (size > 0) { String language = (String)acceptLanguage.get(0); language = HttpFields.valueParameters(language,null); String country = ""; int dash = language.indexOf('-'); if (dash > -1) { country = language.substring(dash + 1).trim(); language = language.substring(0,dash).trim(); } return new Locale(language,country); } return Locale.getDefault(); }
public Locale getLocale() { Enumeration enm = _connection.getRequestFields().getValues(HttpHeaders.ACCEPT_LANGUAGE,HttpFields.__separators); // handle no locale if (enm == null || !enm.hasMoreElements()) return Locale.getDefault(); // sort the list in quality order List acceptLanguage = HttpFields.qualityList(enm); if (acceptLanguage.size() == 0) return Locale.getDefault(); int size = acceptLanguage.size(); if (size > 0) { String language = (String)acceptLanguage.get(0); language = HttpFields.valueParameters(language,null); String country = ""; int dash = language.indexOf('-'); if (dash > -1) { country = language.substring(dash + 1).trim(); language = language.substring(0,dash).trim(); } return new Locale(language,country); } return Locale.getDefault(); }
@Override public Locale getLocale() { Enumeration<String> enm = _fields.getValues(HttpHeader.ACCEPT_LANGUAGE.toString(),HttpFields.__separators); // handle no locale if (enm == null || !enm.hasMoreElements()) return Locale.getDefault(); // sort the list in quality order List<?> acceptLanguage = HttpFields.qualityList(enm); if (acceptLanguage.size() == 0) return Locale.getDefault(); int size = acceptLanguage.size(); if (size > 0) { String language = (String)acceptLanguage.get(0); language = HttpFields.valueParameters(language,null); String country = ""; int dash = language.indexOf('-'); if (dash > -1) { country = language.substring(dash + 1).trim(); language = language.substring(0,dash).trim(); } return new Locale(language,country); } return Locale.getDefault(); }
@Override public Locale getLocale() { Enumeration<String> enm = _fields.getValues(HttpHeader.ACCEPT_LANGUAGE.toString(),HttpFields.__separators); // handle no locale if (enm == null || !enm.hasMoreElements()) return Locale.getDefault(); // sort the list in quality order List<?> acceptLanguage = HttpFields.qualityList(enm); if (acceptLanguage.size() == 0) return Locale.getDefault(); int size = acceptLanguage.size(); if (size > 0) { String language = (String)acceptLanguage.get(0); language = HttpFields.valueParameters(language,null); String country = ""; int dash = language.indexOf('-'); if (dash > -1) { country = language.substring(dash + 1).trim(); language = language.substring(0,dash).trim(); } return new Locale(language,country); } return Locale.getDefault(); }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { HttpField field = getField(name); if (field == null) return -1; String val = valueParameters(field.getValue(), null); if (val == null) return -1; final long date = __dateParser.get().parse(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { Field field = getField(name); if (field == null) return -1; String val = valueParameters(BufferUtil.to8859_1_String(field._value), null); if (val == null) return -1; final long date = __dateParser.get().parse(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { Field field = getField(name); if (field == null) return -1; String val = valueParameters(BufferUtil.to8859_1_String(field._value), null); if (val == null) return -1; final long date = __dateParser.get().parse(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { HttpField field = getField(name); if (field == null) return -1; String val = valueParameters(field.getValue(), null); if (val == null) return -1; final long date = __dateParser.get().parse(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { Field field = getField(name); if (field == null) return -1; String val = valueParameters(BufferUtil.to8859_1_String(field._value), null); if (val == null) return -1; final long date = __dateParser.get().parse(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { Field field = getField(name); if (field == null) return -1; String val = valueParameters(BufferUtil.to8859_1_String(field._value), null); if (val == null) return -1; final long date = __dateParser.get().parse(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { Field field = getField(name); if (field == null) return -1; String val = valueParameters(BufferUtil.to8859_1_String(field._value), null); if (val == null) return -1; final long date = __dateParser.get().parse(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name */ public long getDateField(String name) { HttpField field = getField(name); if (field == null) return -1; String val = valueParameters(field.getValue(), null); if (val == null) return -1; final long date = DateParser.parseDate(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name * @return the value of the field as a number of milliseconds since unix epoch */ public long getDateField(String name) { HttpField field = getField(name); if (field == null) return -1; String val = valueParameters(field.getValue(), null); if (val == null) return -1; final long date = DateParser.parseDate(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name * @return the value of the field as a number of milliseconds since unix epoch */ public long getDateField(String name) { HttpField field = getField(name); if (field == null) return -1; String val = valueParameters(field.getValue(), null); if (val == null) return -1; final long date = DateParser.parseDate(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
@Override public Collection<Part> getParts() throws IOException, ServletException { if (getContentType() == null || !MimeTypes.Type.MULTIPART_FORM_DATA.is(HttpFields.valueParameters(getContentType(),null))) throw new ServletException("Content-Type != multipart/form-data"); return getParts(null); }
/** * Get a header as a date value. Returns the value of a date field, or -1 if not found. The case * of the field name is ignored. * * @param name the case-insensitive field name * @return the value of the field as a number of milliseconds since unix epoch */ public long getDateField(String name) { HttpField field = getField(name); if (field == null) return -1; String val = valueParameters(field.getValue(), null); if (val == null) return -1; final long date = DateParser.parseDate(val); if (date==-1) throw new IllegalArgumentException("Cannot convert date: " + val); return date; }
private MultiMap<String> extractContentParameters() { MultiMap<String> result = new MultiMap<>(); String contentType = getContentType(); if (contentType != null && !contentType.isEmpty()) { contentType = HttpFields.valueParameters(contentType, null); int contentLength = getContentLength(); if (contentLength != 0) { if (MimeTypes.Type.FORM_ENCODED.is(contentType) && _inputState == __NONE && (HttpMethod.POST.is(getMethod()) || HttpMethod.PUT.is(getMethod()))) { extractFormParameters(result); } else if (contentType.startsWith("multipart/form-data") && getAttribute(__MULTIPART_CONFIG_ELEMENT) != null && _multiPartInputStream == null) { extractMultipartParameters(result); } } } return result; }