forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpConfiguration.java
251 lines (212 loc) · 7.07 KB
/
HttpConfiguration.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
package io.quarkus.vertx.http.runtime;
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import io.quarkus.runtime.LaunchMode;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.quarkus.vertx.http.runtime.cors.CORSConfig;
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public class HttpConfiguration {
/**
* Enable the CORS filter.
*/
@ConfigItem(name = "cors")
public boolean corsEnabled;
/**
* The HTTP port
*/
@ConfigItem(defaultValue = "8080")
public int port;
/**
* The HTTP port used to run tests
*/
@ConfigItem(defaultValue = "8081")
public int testPort;
/**
* The HTTP host
*
* In dev/test mode this defaults to localhost, in prod mode this defaults to 0.0.0.0
*
* Defaulting to 0.0.0.0 makes it easier to deploy Quarkus to container, however it
* is not suitable for dev/test mode as other people on the network can connect to your
* development machine.
*/
@ConfigItem
public String host;
/**
* Enable listening to host:port
*/
@ConfigItem(defaultValue = "true")
public boolean hostEnabled;
/**
* The HTTPS port
*/
@ConfigItem(defaultValue = "8443")
public int sslPort;
/**
* The HTTPS port used to run tests
*/
@ConfigItem(defaultValue = "8444")
public int testSslPort;
/**
* If insecure (i.e. http rather than https) requests are allowed. If this is {@code enabled}
* then http works as normal. {@code redirect} will still open the http port, but
* all requests will be redirected to the HTTPS port. {@code disabled} will prevent the HTTP
* port from opening at all.
*/
@ConfigItem(defaultValue = "enabled")
public InsecureRequests insecureRequests;
/**
* If this is true (the default) then HTTP/2 will be enabled.
*
* Note that for browsers to be able to use it HTTPS must be enabled,
* and you must be running on JDK11 or above, as JDK8 does not support
* ALPN.
*/
@ConfigItem(defaultValue = "true")
public boolean http2;
/**
* The CORS config
*/
public CORSConfig cors;
/**
* The SSL config
*/
public ServerSslConfig ssl;
/**
* When set to {@code true}, the HTTP server automatically sends `100 CONTINUE`
* response when the request expects it (with the `Expect: 100-Continue` header).
*/
@ConfigItem(defaultValue = "false", name = "handle-100-continue-automatically")
public boolean handle100ContinueAutomatically;
/**
* The number if IO threads used to perform IO. This will be automatically set to a reasonable value based on
* the number of CPU cores if it is not provided. If this is set to a higher value than the number of Vert.x event
* loops then it will be capped at the number of event loops.
*
* In general this should be controlled by setting quarkus.vertx.event-loops-pool-size, this setting should only
* be used if you want to limit the number of HTTP io threads to a smaller number than the total number of IO threads.
*/
@ConfigItem
public OptionalInt ioThreads;
/**
* Server limits configuration
*/
public ServerLimitsConfig limits;
/**
* Http connection idle timeout
*/
@ConfigItem(defaultValue = "30M", name = "idle-timeout")
public Duration idleTimeout;
/**
* Http connection read timeout for blocking IO. This is the maximum amount of time
* a thread will wait for data, before an IOException will be thrown and the connection
* closed.
*
*/
@ConfigItem(defaultValue = "60s", name = "read-timeout")
public Duration readTimeout;
/**
* Request body related settings
*/
public BodyConfig body;
/**
* The encryption key that is used to store persistent logins (e.g. for form auth). Logins are stored in a persistent
* cookie that is encrypted with AES-256 using a key derived from a SHA-256 hash of the key that is provided here.
*
* If no key is provided then an in-memory one will be generated, this will change on every restart though so it
* is not suitable for production environments. This must be more than 16 characters long for security reasons
*/
@ConfigItem(name = "auth.session.encryption-key")
public Optional<String> encryptionKey;
/**
* Enable socket reuse port (linux/macOs native transport only)
*/
@ConfigItem
public boolean soReusePort;
/**
* Enable tcp quick ack (linux native transport only)
*/
@ConfigItem
public boolean tcpQuickAck;
/**
* Enable tcp cork (linux native transport only)
*/
@ConfigItem
public boolean tcpCork;
/**
* Enable tcp fast open (linux native transport only)
*/
@ConfigItem
public boolean tcpFastOpen;
/**
* The accept backlog, this is how many connections can be waiting to be accepted before connections start being rejected
*/
@ConfigItem(defaultValue = "-1")
public int acceptBacklog;
/**
* Path to a unix domain socket
*/
@ConfigItem(defaultValue = "/var/run/io.quarkus.app.socket")
public String domainSocket;
/**
* Enable listening to host:port
*/
@ConfigItem
public boolean domainSocketEnabled;
/**
* If this is true then the request start time will be recorded to enable logging of total request time.
*
* This has a small performance penalty, so is disabled by default.
*/
@ConfigItem
public boolean recordRequestStartTime;
AccessLogConfig accessLog;
/**
* Configuration that allows setting the same site attributes for cookies.
*/
@ConfigItem
public Map<String, SameSiteCookieConfig> sameSiteCookie;
/**
* Provides a hint (optional) for the default content type of responses generated for
* the errors not handled by the application.
* <p>
* If the client requested a supported content-type in request headers
* (e.g. "Accept: application/json", "Accept: text/html"),
* Quarkus will use that content type.
* <p>
* Otherwise, it will default to the content type configured here.
* </p>
*/
@ConfigItem
public Optional<PayloadHint> unhandledErrorContentTypeDefault;
/**
* Additional HTTP Headers always sent in the response
*/
@ConfigItem
public Map<String, HeaderConfig> header;
/**
* Additional HTTP configuration per path
*/
@ConfigItem
public Map<String, FilterConfig> filter;
public ProxyConfig proxy;
public int determinePort(LaunchMode launchMode) {
return launchMode == LaunchMode.TEST ? testPort : port;
}
public int determineSslPort(LaunchMode launchMode) {
return launchMode == LaunchMode.TEST ? testSslPort : sslPort;
}
public enum InsecureRequests {
ENABLED,
REDIRECT,
DISABLED;
}
public enum PayloadHint {
JSON,
HTML,
}
}