• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / httpunit / 755

14 Feb 2026 07:14PM UTC coverage: 80.526%. Remained the same
755

push

github

hazendaz
[ci] Fix badge

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10124 relevant lines covered (81.44%)

0.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.04
/src/main/java/com/meterware/httpunit/ClientProperties.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2000-2026 Russell Gold
6
 * Copyright 2021-2000 hazendaz
7
 */
8
package com.meterware.httpunit;
9

10
/**
11
 * A class which represents the properties of a web client.
12
 **/
13
public class ClientProperties {
14

15
    /**
16
     * Returns the current defaults for newly created web clients.
17
     *
18
     * @return the default properties
19
     */
20
    public static ClientProperties getDefaultProperties() {
21
        return _defaultProperties;
1✔
22
    }
23

24
    /**
25
     * Specifies the ID information for a client.
26
     *
27
     * @param applicationName
28
     *            the application name
29
     * @param applicationCodeName
30
     *            the application code name
31
     * @param applicationVersion
32
     *            the application version
33
     */
34
    public void setApplicationID(String applicationName, String applicationCodeName, String applicationVersion) {
35
        _applicationCodeName = applicationCodeName;
1✔
36
        _applicationName = applicationName;
1✔
37
        _applicationVersion = applicationVersion;
1✔
38
    }
1✔
39

40
    /**
41
     * Gets the application code name.
42
     *
43
     * @return the application code name
44
     */
45
    public String getApplicationCodeName() {
46
        return _applicationCodeName;
1✔
47
    }
48

49
    /**
50
     * Sets the application code name.
51
     *
52
     * @param applicationCodeName
53
     *            the new application code name
54
     */
55
    public void setApplicationCodeName(String applicationCodeName) {
56
        _applicationCodeName = applicationCodeName;
×
57
    }
×
58

59
    /**
60
     * Gets the application name.
61
     *
62
     * @return the application name
63
     */
64
    public String getApplicationName() {
65
        return _applicationName;
1✔
66
    }
67

68
    /**
69
     * Sets the application name.
70
     *
71
     * @param applicationName
72
     *            the new application name
73
     */
74
    public void setApplicationName(String applicationName) {
75
        _applicationName = applicationName;
×
76
    }
×
77

78
    /**
79
     * Gets the application version.
80
     *
81
     * @return the application version
82
     */
83
    public String getApplicationVersion() {
84
        return _applicationVersion;
1✔
85
    }
86

87
    /**
88
     * Sets the application version.
89
     *
90
     * @param applicationVersion
91
     *            the new application version
92
     */
93
    public void setApplicationVersion(String applicationVersion) {
94
        _applicationVersion = applicationVersion;
×
95
    }
×
96

97
    /**
98
     * Returns the user agent identification. Unless this has been set explicitly, it will default to the application
99
     * code name followed by a slash and the application version.
100
     *
101
     * @return the user agent
102
     */
103
    public String getUserAgent() {
104
        return _userAgent != null ? _userAgent : _applicationCodeName + '/' + _applicationVersion;
1✔
105
    }
106

107
    /**
108
     * Sets the user agent.
109
     *
110
     * @param userAgent
111
     *            the new user agent
112
     */
113
    public void setUserAgent(String userAgent) {
114
        _userAgent = userAgent;
1✔
115
    }
1✔
116

117
    /**
118
     * Gets the platform.
119
     *
120
     * @return the platform
121
     */
122
    public String getPlatform() {
123
        return _platform;
1✔
124
    }
125

126
    /**
127
     * Sets the platform.
128
     *
129
     * @param platform
130
     *            the new platform
131
     */
132
    public void setPlatform(String platform) {
133
        _platform = platform;
1✔
134
    }
1✔
135

136
    /**
137
     * A shortcut for setting both availableScreenWidth and availableScreenHeight at one time.
138
     *
139
     * @param width
140
     *            the width
141
     * @param height
142
     *            the height
143
     */
144
    public void setAvailableScreenSize(int width, int height) {
145
        _availWidth = width;
1✔
146
        _availHeight = height;
1✔
147
    }
1✔
148

149
    /**
150
     * Gets the available screen width.
151
     *
152
     * @return the available screen width
153
     */
154
    public int getAvailableScreenWidth() {
155
        return _availWidth;
1✔
156
    }
157

158
    /**
159
     * Sets the available screen width.
160
     *
161
     * @param availWidth
162
     *            the new available screen width
163
     */
164
    public void setAvailableScreenWidth(int availWidth) {
165
        _availWidth = availWidth;
×
166
    }
×
167

168
    /**
169
     * Gets the avail height.
170
     *
171
     * @return the avail height
172
     */
173
    public int getAvailHeight() {
174
        return _availHeight;
1✔
175
    }
176

177
    /**
178
     * Sets the avail height.
179
     *
180
     * @param availHeight
181
     *            the new avail height
182
     */
183
    public void setAvailHeight(int availHeight) {
184
        _availHeight = availHeight;
×
185
    }
×
186

187
    /**
188
     * Returns true if the client should accept and transmit cookies. The default is to accept them.
189
     *
190
     * @return true, if is accept cookies
191
     */
192
    public boolean isAcceptCookies() {
193
        return _acceptCookies;
1✔
194
    }
195

196
    /**
197
     * Specifies whether the client should accept and send cookies.
198
     *
199
     * @param acceptCookies
200
     *            the new accept cookies
201
     */
202
    public void setAcceptCookies(boolean acceptCookies) {
203
        _acceptCookies = acceptCookies;
1✔
204
    }
1✔
205

206
    /**
207
     * Returns true if the client will accept GZIP encoding of responses. The default is to accept GZIP encoding.
208
     *
209
     * @return true, if is accept gzip
210
     */
211
    public boolean isAcceptGzip() {
212
        return _acceptGzip;
1✔
213
    }
214

215
    /**
216
     * Specifies whether the client will accept GZIP encoded responses. The default is true.
217
     *
218
     * @param acceptGzip
219
     *            the new accept gzip
220
     */
221
    public void setAcceptGzip(boolean acceptGzip) {
222
        _acceptGzip = acceptGzip;
1✔
223
    }
1✔
224

225
    /**
226
     * get Maximum number of redirect requests.
227
     *
228
     * @return it
229
     */
230
    public int getMaxRedirects() {
231
        return _maxRedirects;
1✔
232
    }
233

234
    /**
235
     * set the maximum number of redirects.
236
     *
237
     * @param maxRedirects
238
     *            the new max redirects
239
     */
240
    public void setMaxRedirects(int maxRedirects) {
241
        _maxRedirects = maxRedirects;
1✔
242
    }
1✔
243

244
    /**
245
     * Returns true if the client should automatically follow page redirect requests (status 3xx). By default, this is
246
     * true.
247
     *
248
     * @return true, if is auto redirect
249
     */
250
    public boolean isAutoRedirect() {
251
        return _autoRedirect;
1✔
252
    }
253

254
    /**
255
     * Determines whether the client should automatically follow page redirect requests (status 3xx). By default, this
256
     * is true in order to simulate normal browser operation.
257
     *
258
     * @param autoRedirect
259
     *            the new auto redirect
260
     */
261
    public void setAutoRedirect(boolean autoRedirect) {
262
        _autoRedirect = autoRedirect;
1✔
263
    }
1✔
264

265
    /**
266
     * Returns true if the client should automatically follow page refresh requests. By default, this is false, so that
267
     * programs can verify the redirect page presented to users before the browser switches to the new page.
268
     *
269
     * @return true, if is auto refresh
270
     */
271
    public boolean isAutoRefresh() {
272
        return _autoRefresh;
1✔
273
    }
274

275
    /**
276
     * Specifies whether the client should automatically follow page refresh requests. By default, this is false, so
277
     * that programs can verify the redirect page presented to users before the browser switches to the new page.
278
     * Setting this to true can cause an infinite loop on pages that refresh themselves.
279
     *
280
     * @param autoRefresh
281
     *            the new auto refresh
282
     */
283
    public void setAutoRefresh(boolean autoRefresh) {
284
        _autoRefresh = autoRefresh;
1✔
285
    }
1✔
286

287
    /**
288
     * Checks if is iframe supported.
289
     *
290
     * @return true, if is iframe supported
291
     */
292
    public boolean isIframeSupported() {
293
        return _iframeSupported;
1✔
294
    }
295

296
    /**
297
     * Sets the iframe supported.
298
     *
299
     * @param iframeSupported
300
     *            the new iframe supported
301
     */
302
    public void setIframeSupported(boolean iframeSupported) {
303
        _iframeSupported = iframeSupported;
×
304
    }
×
305

306
    /**
307
     * Gets the override context type.
308
     *
309
     * @return the overriding content type
310
     *
311
     * @see getOverrideContentType
312
     *
313
     * @deprecated since 1.8 see BR 2595566 - name of getter is a typo
314
     */
315
    @Deprecated
316
    public String getOverrideContextType() {
317
        return getOverrideContentType();
×
318
    }
319

320
    /**
321
     * Sets the override context type.
322
     *
323
     * @param overrideContentType
324
     *            the content type
325
     *
326
     * @see setOverrideContentType
327
     *
328
     * @deprecated since 1.8 see BR 2595566 - name of setter is a typo
329
     */
330
    @Deprecated
331
    public void setOverrideContextType(String overrideContentType) {
332
        setOverrideContentType(overrideContentType);
1✔
333
    }
1✔
334

335
    /**
336
     * Returns the content type (if any) to use instead of the one specified by the server. Defaults to null.
337
     *
338
     * @return the overriding content type, or null if none is specified.
339
     */
340
    public String getOverrideContentType() {
341
        return _overrideContentType;
1✔
342
    }
343

344
    /**
345
     * All responses to this client will use the specified content type rather than the one specified by the server.
346
     * Setting this to "text/html" will force all reponses to be interpreted as HTML.
347
     *
348
     * @param overrideContentType
349
     *            the new override to apply to context types.
350
     */
351
    public void setOverrideContentType(String overrideContentType) {
352
        _overrideContentType = overrideContentType;
1✔
353
    }
1✔
354

355
    /**
356
     * Specifies a listener for DNS requests from the client.
357
     *
358
     * @param dnsListener
359
     *            the new listener.
360
     */
361
    public void setDnsListener(DNSListener dnsListener) {
362
        _dnsListener = dnsListener;
×
363
    }
×
364

365
    /**
366
     * Returns the listener for DNS requests to be used by the client.
367
     *
368
     * @return the currently specified DNS listener, or null if none is specified.
369
     */
370
    DNSListener getDnsListener() {
371
        return _dnsListener;
1✔
372
    }
373

374
    /**
375
     * Checks if is send referer.
376
     *
377
     * @return the whether Referer information should be stripped from the header
378
     */
379
    public boolean isSendReferer() {
380
        return _sendReferer;
1✔
381
    }
382

383
    /**
384
     * set whether Referer information should be stripped.
385
     *
386
     * @param referer
387
     *            the _sendReferer to set
388
     */
389
    public void setSendReferer(boolean referer) {
390
        _sendReferer = referer;
1✔
391
    }
1✔
392

393
    /**
394
     * Clone properties.
395
     *
396
     * @return the client properties
397
     */
398
    ClientProperties cloneProperties() {
399
        return new ClientProperties(this);
1✔
400
    }
401

402
    /** The application code name. */
403
    private String _applicationCodeName = "httpunit";
1✔
404

405
    /** The application name. */
406
    private String _applicationName = "HttpUnit";
1✔
407

408
    /** The application version. */
409
    private String _applicationVersion = "1.5";
1✔
410

411
    /** The user agent. */
412
    private String _userAgent;
413

414
    /** The platform. */
415
    private String _platform = "Java";
1✔
416

417
    /** The override content type. */
418
    private String _overrideContentType = null;
1✔
419

420
    /** The avail width. */
421
    private int _availWidth = 800;
1✔
422

423
    /** The avail height. */
424
    private int _availHeight = 600;
1✔
425

426
    /** The max redirects. */
427
    private int _maxRedirects = 5;
1✔
428

429
    /** The iframe supported. */
430
    private boolean _iframeSupported = true;
1✔
431

432
    /** The accept cookies. */
433
    private boolean _acceptCookies = true;
1✔
434

435
    /** The accept gzip. */
436
    private boolean _acceptGzip = true;
1✔
437

438
    /** The auto redirect. */
439
    private boolean _autoRedirect = true;
1✔
440

441
    /** The auto refresh. */
442
    private boolean _autoRefresh = false;
1✔
443

444
    /** The dns listener. */
445
    private DNSListener _dnsListener;
446

447
    /** The send referer. */
448
    private boolean _sendReferer;
449

450
    /** The default properties. */
451
    private static ClientProperties _defaultProperties = new ClientProperties();
1✔
452

453
    /**
454
     * default Constructor.
455
     */
456
    private ClientProperties() {
1✔
457
        _sendReferer = true;
1✔
458
    }
1✔
459

460
    /**
461
     * copy constructor.
462
     *
463
     * @param source
464
     *            - the ClientProperties to copy from
465
     */
466
    private ClientProperties(ClientProperties source) {
1✔
467
        _applicationCodeName = source._applicationCodeName;
1✔
468
        _applicationName = source._applicationName;
1✔
469
        _applicationVersion = source._applicationVersion;
1✔
470
        _userAgent = source._userAgent;
1✔
471
        _platform = source._platform;
1✔
472
        _overrideContentType = source._overrideContentType;
1✔
473
        _iframeSupported = source._iframeSupported;
1✔
474
        _acceptCookies = source._acceptCookies;
1✔
475
        _acceptGzip = source._acceptGzip;
1✔
476
        _autoRedirect = source._autoRedirect;
1✔
477
        _autoRefresh = source._autoRefresh;
1✔
478
        _sendReferer = source._sendReferer;
1✔
479
        _maxRedirects = source._maxRedirects;
1✔
480
    }
1✔
481

482
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc