66import java .util .HashSet ;
77import java .util .List ;
88import java .util .Set ;
9+ import java .util .regex .Matcher ;
10+ import java .util .regex .Pattern ;
911
1012import org .apache .commons .collections4 .CollectionUtils ;
1113import org .apache .commons .collections4 .ListUtils ;
@@ -33,8 +35,9 @@ public class CommonConfig {
3335 private String version ;
3436 private boolean blockHoundEnable ;
3537 private String cookieName ;
36- private int maxQueryRequestSizeInMb = 10 ;
37- private int maxQueryResponseSizeInMb = 10 ;
38+ private String maxUploadSize = "20MB" ;
39+ private String maxQueryRequestSize = "20MB" ;
40+ private String maxQueryResponseSize = "20MB" ;
3841 private Query query = new Query ();
3942 private Cookie cookie = new Cookie ();
4043 private JsExecutor jsExecutor = new JsExecutor ();
@@ -48,6 +51,37 @@ public boolean isEnterpriseMode() {
4851 return workspace .getMode () == WorkspaceMode .ENTERPRISE ;
4952 }
5053
54+ private static final Pattern HUMAN_DATA_SIZE_PATTERN = Pattern .compile ("^([ \t ]*)(?<number>\\ d+(\\ .\\ d+)?)([ \t ]*)(?<unit>[kKmMgGtT]{1})?([bB \t ]*)$" );
55+ public static String normalizeDataUnits (String dataWithUnits )
56+ {
57+ String normalized = dataWithUnits ;
58+ Matcher m = HUMAN_DATA_SIZE_PATTERN .matcher (dataWithUnits );
59+ if (m .matches ())
60+ {
61+ normalized = m .group ("number" );
62+ if (StringUtils .isNotBlank (m .group ("unit" )))
63+ {
64+ normalized += m .group ("unit" ).toUpperCase () + "B" ;
65+ }
66+ }
67+ return normalized ;
68+ }
69+
70+ public void setMaxUploadSize (String size )
71+ {
72+ this .maxUploadSize = normalizeDataUnits (size );
73+ }
74+
75+ public void setMaxQueryRequestSize (String size )
76+ {
77+ this .maxQueryRequestSize = normalizeDataUnits (size );
78+ }
79+
80+ public void setMaxQueryResponseSize (String size )
81+ {
82+ this .maxQueryResponseSize = normalizeDataUnits (size );
83+ }
84+
5185 @ Data
5286 public static class Domain {
5387 private String defaultValue ;
0 commit comments