Issue #1676 remove deprecated methods on HttpFields

This commit is contained in:
Greg Wilkins 2017-07-19 10:16:36 +02:00
parent d14c53ed30
commit 5a05e953b9
4 changed files with 4 additions and 142 deletions

View File

@ -523,53 +523,6 @@ public class HttpFields implements Iterable<HttpField>
return Collections.enumeration(empty);
}
/**
* Get multi field values with separator. The multiple values can be represented as separate
* headers of the same name, or by a single header using the separator(s), or a combination of
* both. Separators may be quoted.
*
* @param name the case-insensitive field name
* @param separators String of separators.
* @return Enumeration of the values, or null if no such header.
*/
@Deprecated
public Enumeration<String> getValues(String name, final String separators)
{
final Enumeration<String> e = getValues(name);
if (e == null)
return null;
return new Enumeration<String>()
{
QuotedStringTokenizer tok = null;
@Override
public boolean hasMoreElements()
{
if (tok != null && tok.hasMoreElements()) return true;
while (e.hasMoreElements())
{
String value = e.nextElement();
if (value!=null)
{
tok = new QuotedStringTokenizer(value, separators, false, false);
if (tok.hasMoreElements()) return true;
}
}
tok = null;
return false;
}
@Override
public String nextElement() throws NoSuchElementException
{
if (!hasMoreElements()) throw new NoSuchElementException();
String next = (String) tok.nextElement();
if (next != null) next = next.trim();
return next;
}
};
}
public void put(HttpField field)
{
boolean put=false;
@ -982,87 +935,6 @@ public class HttpFields implements Iterable<HttpField>
return value.substring(0, i).trim();
}
@Deprecated
private static final Float __one = new Float("1.0");
@Deprecated
private static final Float __zero = new Float("0.0");
@Deprecated
private static final Trie<Float> __qualities = new ArrayTernaryTrie<>();
static
{
__qualities.put("*", __one);
__qualities.put("1.0", __one);
__qualities.put("1", __one);
__qualities.put("0.9", new Float("0.9"));
__qualities.put("0.8", new Float("0.8"));
__qualities.put("0.7", new Float("0.7"));
__qualities.put("0.66", new Float("0.66"));
__qualities.put("0.6", new Float("0.6"));
__qualities.put("0.5", new Float("0.5"));
__qualities.put("0.4", new Float("0.4"));
__qualities.put("0.33", new Float("0.33"));
__qualities.put("0.3", new Float("0.3"));
__qualities.put("0.2", new Float("0.2"));
__qualities.put("0.1", new Float("0.1"));
__qualities.put("0", __zero);
__qualities.put("0.0", __zero);
}
@Deprecated
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++;
Float q = __qualities.get(value, qe, value.length() - qe);
if (q != null)
return q;
}
Map<String,String> params = new HashMap<>(4);
valueParameters(value, params);
String qs = params.get("q");
if (qs==null)
qs="*";
Float q = __qualities.get(qs);
if (q == null)
{
try
{
q = new Float(qs);
}
catch (Exception e)
{
q = __one;
}
}
return q;
}
/**
* List values in quality order.
*
* @param e Enumeration of values with quality parameters
* @return values in quality order.
*/
@Deprecated
public static List<String> qualityList(Enumeration<String> e)
{
if (e == null || !e.hasMoreElements())
return Collections.emptyList();
QuotedQualityCSV values = new QuotedQualityCSV();
while(e.hasMoreElements())
values.addValue(e.nextElement());
return values.getValues();
}
private class Itr implements Iterator<HttpField>
{
int _cursor; // index of next element to return

View File

@ -317,7 +317,7 @@ public class HttpFieldsTest
assertEquals(e.nextElement(), "value0C,value0D");
assertEquals(false, e.hasMoreElements());
e = fields.getValues("name0",",");
e = Collections.enumeration(fields.getCSV("name0",false));
assertEquals(true, e.hasMoreElements());
assertEquals(e.nextElement(), "value0A");
assertEquals(true, e.hasMoreElements());
@ -328,7 +328,7 @@ public class HttpFieldsTest
assertEquals(e.nextElement(), "value0D");
assertEquals(false, e.hasMoreElements());
e = fields.getValues("name1",",");
e = Collections.enumeration(fields.getCSV("name1",false));
assertEquals(true, e.hasMoreElements());
assertEquals(e.nextElement(), "value1A");
assertEquals(true, e.hasMoreElements());

View File

@ -260,8 +260,7 @@ public class PartialRFC2616Test
HttpFields fields=new HttpFields();
fields.put("Q","bbb;q=0.5,aaa,ccc;q=0.002,d;q=0,e;q=0.0001,ddd;q=0.001,aa2,abb;q=0.7");
Enumeration<String> qualities=fields.getValues("Q",", \t");
List<String> list=HttpFields.qualityList(qualities);
List<String> list=fields.getQualityCSV("Q");
assertEquals("Quality parameters","aaa",HttpFields.valueParameters(list.get(0),null));
assertEquals("Quality parameters","aa2",HttpFields.valueParameters(list.get(1),null));
assertEquals("Quality parameters","abb",HttpFields.valueParameters(list.get(2),null));

View File

@ -471,7 +471,7 @@ public class DoSFilter implements Filter
@Override
public void run()
{
closeConnection(request, response, thread);
onRequestTimeout(request, response, thread);
}
};
Scheduler.Task task = _scheduler.schedule(requestTimeout, getMaxRequestMs(), TimeUnit.MILLISECONDS);
@ -510,15 +510,6 @@ public class DoSFilter implements Filter
handlingThread.interrupt();
}
/**
* @deprecated use {@link #onRequestTimeout(HttpServletRequest, HttpServletResponse, Thread)} instead
*/
@Deprecated
protected void closeConnection(HttpServletRequest request, HttpServletResponse response, Thread thread)
{
onRequestTimeout(request, response, thread);
}
/**
* Get priority for this request, based on user type
*