6
6
import java .util .HashSet ;
7
7
import java .util .List ;
8
8
import java .util .Set ;
9
+ import java .util .regex .Matcher ;
10
+ import java .util .regex .Pattern ;
9
11
10
12
import org .apache .commons .collections4 .CollectionUtils ;
11
13
import org .apache .commons .collections4 .ListUtils ;
@@ -33,8 +35,9 @@ public class CommonConfig {
33
35
private String version ;
34
36
private boolean blockHoundEnable ;
35
37
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" ;
38
41
private Query query = new Query ();
39
42
private Cookie cookie = new Cookie ();
40
43
private JsExecutor jsExecutor = new JsExecutor ();
@@ -48,6 +51,37 @@ public boolean isEnterpriseMode() {
48
51
return workspace .getMode () == WorkspaceMode .ENTERPRISE ;
49
52
}
50
53
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
+
51
85
@ Data
52
86
public static class Domain {
53
87
private String defaultValue ;
0 commit comments