forked from restlet/restlet-framework-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponse.java
More file actions
844 lines (771 loc) · 27.5 KB
/
Response.java
File metadata and controls
844 lines (771 loc) · 27.5 KB
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
/**
* Copyright 2005-2013 Restlet S.A.S.
*
* The contents of this file are subject to the terms of one of the following
* open source licenses: Apache 2.0 or LGPL 3.0 or LGPL 2.1 or CDDL 1.0 or EPL
* 1.0 (the "Licenses"). You can select the license that you prefer but you may
* not use this file except in compliance with one of these Licenses.
*
* You can obtain a copy of the Apache 2.0 license at
* http://www.opensource.org/licenses/apache-2.0
*
* You can obtain a copy of the LGPL 3.0 license at
* http://www.opensource.org/licenses/lgpl-3.0
*
* You can obtain a copy of the LGPL 2.1 license at
* http://www.opensource.org/licenses/lgpl-2.1
*
* You can obtain a copy of the CDDL 1.0 license at
* http://www.opensource.org/licenses/cddl1
*
* You can obtain a copy of the EPL 1.0 license at
* http://www.opensource.org/licenses/eclipse-1.0
*
* See the Licenses for the specific language governing permissions and
* limitations under the Licenses.
*
* Alternatively, you can obtain a royalty free commercial license with less
* limitations, transferable or non-transferable, directly at
* http://www.restlet.com/products/restlet-framework
*
* Restlet is a registered trademark of Restlet S.A.S.
*/
package org.restlet;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import org.restlet.data.AuthenticationInfo;
import org.restlet.data.ChallengeRequest;
import org.restlet.data.CookieSetting;
import org.restlet.data.Dimension;
import org.restlet.data.Method;
import org.restlet.data.Reference;
import org.restlet.data.ServerInfo;
import org.restlet.data.Status;
import org.restlet.util.Series;
/**
* Generic response sent by server connectors. It is then received by client
* connectors. Responses are uniform across all types of connectors, protocols
* and components.
*
* @see org.restlet.Request
* @see org.restlet.Uniform
* @author Jerome Louvel
*/
public class Response extends Message {
// [ifndef gwt] member
private static final ThreadLocal<Response> CURRENT = new ThreadLocal<Response>();
// [ifndef gwt] method
/**
* Returns the response associated to the current thread.
*
* Warning: this method should only be used under duress. You should by
* default prefer obtaining the current context using methods such as
* {@link org.restlet.resource.Resource#getResponse()}.
*
* This variable is stored internally as a thread local variable and updated
* each time a call is handled by a Restlet via the
* {@link Restlet#handle(org.restlet.Request, org.restlet.Response)} method.
*
* @return The current context.
*/
public static Response getCurrent() {
return CURRENT.get();
}
// [ifndef gwt] method
/**
* Sets the response associated with the current thread.
*
* @param response
* The thread's response.
*/
public static void setCurrent(Response response) {
CURRENT.set(response);
}
/**
* Estimated amount of time since a response was generated or revalidated by
* the origin server.
*/
private volatile int age;
/** The set of methods allowed on the requested resource. */
private volatile Set<Method> allowedMethods;
/**
* The authentication information sent by an origin server to a client in
* the case of a successful authentication attempt.
*/
private volatile AuthenticationInfo authenticationInfo;
/** Indicates if the response should be automatically committed. */
private volatile boolean autoCommitting;
/** The authentication requests sent by an origin server to a client. */
private volatile List<ChallengeRequest> challengeRequests;
/** Indicates if the response has been committed. */
private volatile boolean committed;
/** The cookie settings provided by the server. */
private volatile Series<CookieSetting> cookieSettings;
/** The set of dimensions on which the response entity may vary. */
private volatile Set<Dimension> dimensions;
/** The reference used for redirections or creations. */
private volatile Reference locationRef;
/** The authentication requests sent by a proxy to a client. */
private volatile List<ChallengeRequest> proxyChallengeRequests;
/** The associated request. */
private volatile Request request;
/**
* Indicates how long the service is expected to be unavailable to the
* requesting client.
*/
private volatile Date retryAfter;
/** The server-specific information. */
private volatile ServerInfo serverInfo;
/** The status. */
private volatile Status status;
/**
* Constructor.
*
* @param request
* The request associated to this response.
*/
public Response(Request request) {
this.age = 0;
this.allowedMethods = null;
this.autoCommitting = true;
this.challengeRequests = null;
this.cookieSettings = null;
this.committed = false;
this.dimensions = null;
this.locationRef = null;
this.proxyChallengeRequests = null;
this.request = request;
this.retryAfter = null;
this.serverInfo = null;
this.status = Status.SUCCESS_OK;
}
/**
* Ask the connector to abort the related network connection, for example
* immediately closing the socket.
*/
public void abort() {
getRequest().abort();
}
/**
* Asks the server connector to immediately commit the given response,
* making it ready to be sent back to the client. Note that all server
* connectors don't necessarily support this feature.<br>
* <br>
* When the response is in autoCommit mode (see related property), then
* calling this method isn't necessary. Also, be aware that committing the
* response doesn't necessarily means that is will be immediately be written
* on the network as some buffering can occurs. If you want to ensure that
* response buffers are flushed,<br>
* <br>
* Note that this calls back {@link Request#commit(Response)} on the parent
* request which holds the link with the underlying network connection.
*/
public void commit() {
getRequest().commit(this);
}
/**
* Asks the server connector to immediately flush the network buffers. Note
* that this calls back {@link Request#flushBuffers()} on the parent request
* which holds the link with the underlying network connection.
*
* @throws IOException
*/
@Override
public void flushBuffers() throws IOException {
getRequest().flushBuffers();
}
/**
* Returns the estimated amount of time since a response was generated or
* revalidated by the origin server. Origin servers should leave the 0
* default value. Only caches are expected to set this property.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the "Age"
* header.
*
* @return The response age.
*/
public int getAge() {
return age;
}
/**
* Returns the modifiable set of methods allowed on the requested resource.
* This property only has to be updated when a status
* CLIENT_ERROR_METHOD_NOT_ALLOWED is set. Creates a new instance if no one
* has been set.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Allow" header.
*
* @return The set of allowed methods.
*/
public Set<Method> getAllowedMethods() {
// Lazy initialization with double-check.
Set<Method> a = this.allowedMethods;
if (a == null) {
synchronized (this) {
a = this.allowedMethods;
if (a == null) {
this.allowedMethods = a = new CopyOnWriteArraySet<Method>();
}
}
}
return a;
}
/**
* Returns information sent by an origin server related to an successful
* authentication attempt. If none is available, null is returned.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Authentication-Info" header.
*
* @return The authentication information provided by the server.
*/
public AuthenticationInfo getAuthenticationInfo() {
return this.authenticationInfo;
}
/**
* Returns the list of authentication requests sent by an origin server to a
* client. If none is available, an empty list is returned.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "WWW-Authenticate" header.
*
* @return The list of authentication requests.
*/
public List<ChallengeRequest> getChallengeRequests() {
// Lazy initialization with double-check.
List<ChallengeRequest> cr = this.challengeRequests;
if (cr == null) {
synchronized (this) {
cr = this.challengeRequests;
if (cr == null) {
this.challengeRequests = cr = new CopyOnWriteArrayList<ChallengeRequest>();
}
}
}
return cr;
}
/**
* Returns the modifiable series of cookie settings provided by the server.
* Creates a new instance if no one has been set.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Set-Cookie" and "Set-Cookie2" headers.
*
* @return The cookie settings provided by the server.
*/
public Series<CookieSetting> getCookieSettings() {
// Lazy initialization with double-check.
Series<CookieSetting> c = this.cookieSettings;
if (c == null) {
synchronized (this) {
c = this.cookieSettings;
if (c == null) {
// [ifndef gwt] instruction
this.cookieSettings = c = new Series<CookieSetting>(
CookieSetting.class);
// [ifdef gwt] instruction uncomment
// this.cookieSettings = c = new
// org.restlet.engine.util.CookieSettingSeries();
}
}
}
return c;
}
/**
* Returns the modifiable set of selecting dimensions on which the response
* entity may vary. If some server-side content negotiation is done, this
* set should be properly updated, other it can be left empty. Creates a new
* instance if no one has been set.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Vary" header.
*
* @return The set of dimensions on which the response entity may vary.
*/
public Set<Dimension> getDimensions() {
if (this.dimensions == null) {
this.dimensions = new CopyOnWriteArraySet<Dimension>();
}
return this.dimensions;
}
/**
* Returns the location reference. This is the reference that the client
* should follow for redirections or resource creations.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Location" header.
*
* @return The redirection reference.
*/
public Reference getLocationRef() {
return this.locationRef;
}
/**
* Returns the list of authentication requests sent by an origin server to a
* client. If none is available, an empty list is returned.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Proxy-Authenticate" header.
*
* @return The list of authentication requests.
*/
public List<ChallengeRequest> getProxyChallengeRequests() {
// Lazy initialization with double-check.
List<ChallengeRequest> cr = this.proxyChallengeRequests;
if (cr == null) {
synchronized (this) {
cr = this.proxyChallengeRequests;
if (cr == null) {
this.proxyChallengeRequests = cr = new CopyOnWriteArrayList<ChallengeRequest>();
}
}
}
return cr;
}
/**
* Returns the associated request
*
* @return The associated request
*/
public Request getRequest() {
return this.request;
}
/**
* Indicates how long the service is expected to be unavailable to the
* requesting client. Default value is null.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Retry-After" header.
*
* @return Date after with a retry attempt could occur.
*/
public Date getRetryAfter() {
return retryAfter;
}
/**
* Returns the server-specific information. Creates a new instance if no one
* has been set.
*
* @return The server-specific information.
*/
public ServerInfo getServerInfo() {
// Lazy initialization with double-check.
ServerInfo s = this.serverInfo;
if (s == null) {
synchronized (this) {
s = this.serverInfo;
if (s == null) {
this.serverInfo = s = new ServerInfo();
}
}
}
return s;
}
/**
* Returns the status.
*
* @return The status.
*/
public Status getStatus() {
return this.status;
}
/**
* Indicates if the response should be automatically committed. When
* processing a request on the server-side, setting this property to 'false'
* let you ask to the server connector to wait before sending the response
* back to the client when the initial calling thread returns. This will let
* you do further updates to the response and manually calling
* {@link #commit()} later on, using another thread.
*
* @return True if the response should be automatically committed.
*/
public boolean isAutoCommitting() {
return autoCommitting;
}
/**
* Indicates if the response has already been committed.
*
* @return True if the response has already been committed.
*/
public boolean isCommitted() {
return committed;
}
@Override
public boolean isConfidential() {
return getRequest().isConfidential();
}
/**
* Indicates if the response is final or provisional. It relies on the
* {@link Status#isInformational()} method.
*
* @return True if the response is final.
*/
public boolean isFinal() {
return !getStatus().isInformational();
}
/**
* Indicates if the response is provisional or final. It relies on the
* {@link Status#isInformational()} method.
*
* @return True if the response is provisional.
*/
public boolean isProvisional() {
return getStatus().isInformational();
}
/**
* Permanently redirects the client to a target URI. The client is expected
* to reuse the same method for the new request.
*
* @param targetRef
* The target URI reference.
*/
public void redirectPermanent(Reference targetRef) {
setLocationRef(targetRef);
setStatus(Status.REDIRECTION_PERMANENT);
}
/**
* Permanently redirects the client to a target URI. The client is expected
* to reuse the same method for the new request.<br>
* <br>
* If you pass a relative target URI, it will be resolved with the current
* base reference of the request's resource reference (see
* {@link Request#getResourceRef()} and {@link Reference#getBaseRef()}.
*
* @param targetUri
* The target URI.
*/
public void redirectPermanent(String targetUri) {
setLocationRef(targetUri);
setStatus(Status.REDIRECTION_PERMANENT);
}
/**
* Redirects the client to a different URI that SHOULD be retrieved using a
* GET method on that resource. This method exists primarily to allow the
* output of a POST-activated script to redirect the user agent to a
* selected resource. The new URI is not a substitute reference for the
* originally requested resource.
*
* @param targetRef
* The target reference.
*/
public void redirectSeeOther(Reference targetRef) {
setLocationRef(targetRef);
setStatus(Status.REDIRECTION_SEE_OTHER);
}
/**
* Redirects the client to a different URI that SHOULD be retrieved using a
* GET method on that resource. This method exists primarily to allow the
* output of a POST-activated script to redirect the user agent to a
* selected resource. The new URI is not a substitute reference for the
* originally requested resource.<br>
* <br>
* If you pass a relative target URI, it will be resolved with the current
* base reference of the request's resource reference (see
* {@link Request#getResourceRef()} and {@link Reference#getBaseRef()}.
*
* @param targetUri
* The target URI.
*/
public void redirectSeeOther(String targetUri) {
setLocationRef(targetUri);
setStatus(Status.REDIRECTION_SEE_OTHER);
}
/**
* Temporarily redirects the client to a target URI. The client is expected
* to reuse the same method for the new request.
*
* @param targetRef
* The target reference.
*/
public void redirectTemporary(Reference targetRef) {
setLocationRef(targetRef);
setStatus(Status.REDIRECTION_TEMPORARY);
}
/**
* Temporarily redirects the client to a target URI. The client is expected
* to reuse the same method for the new request.<br>
* <br>
* If you pass a relative target URI, it will be resolved with the current
* base reference of the request's resource reference (see
* {@link Request#getResourceRef()} and {@link Reference#getBaseRef()}.
*
* @param targetUri
* The target URI.
*/
public void redirectTemporary(String targetUri) {
setLocationRef(targetUri);
setStatus(Status.REDIRECTION_TEMPORARY);
}
/**
* Sets the estimated amount of time since a response was generated or
* revalidated by the origin server. Origin servers should leave the 0
* default value. Only caches are expected to set this property.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the "Age"
* header.
*
* @param age
* The response age.
*/
public void setAge(int age) {
this.age = age;
}
/**
* Sets the set of methods allowed on the requested resource. The set
* instance set must be thread-safe (use {@link CopyOnWriteArraySet} for
* example.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Allow" header.
*
* @param allowedMethods
* The set of methods allowed on the requested resource.
*/
public void setAllowedMethods(Set<Method> allowedMethods) {
synchronized (getAllowedMethods()) {
if (allowedMethods != this.allowedMethods) {
this.allowedMethods.clear();
if (allowedMethods != null) {
this.allowedMethods.addAll(allowedMethods);
}
}
}
}
/**
* Sets the authentication information sent by an origin server to a client
* after a successful authentication attempt.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Authentication-Info" header.
*
* @param authenticationInfo
* The data returned by the server in response to successful
* authentication.
*/
public void setAuthenticationInfo(AuthenticationInfo authenticationInfo) {
this.authenticationInfo = authenticationInfo;
}
/**
* Indicates if the response should be automatically committed.
*
* @param autoCommitting
* True if the response should be automatically committed
*/
public void setAutoCommitting(boolean autoCommitting) {
this.autoCommitting = autoCommitting;
}
/**
* Sets the list of authentication requests sent by an origin server to a
* client. Note that when used with HTTP connectors, this property maps to
* the "WWW-Authenticate" header. This method clears the current list and
* adds all entries in the parameter list.
*
* @param challengeRequests
* A list of authentication requests sent by an origin server to
* a client.
*/
public void setChallengeRequests(List<ChallengeRequest> challengeRequests) {
synchronized (getChallengeRequests()) {
if (challengeRequests != getChallengeRequests()) {
getChallengeRequests().clear();
if (challengeRequests != null) {
getChallengeRequests().addAll(challengeRequests);
}
}
}
}
/**
* Indicates if the response has already been committed.
*
* @param committed
* True if the response has already been committed.
*/
public void setCommitted(boolean committed) {
this.committed = committed;
}
/**
* Sets the modifiable series of cookie settings provided by the server.
* Note that when used with HTTP connectors, this property maps to the
* "Set-Cookie" and "Set-Cookie2" headers. This method clears the current
* series and adds all entries in the parameter series.
*
* @param cookieSettings
* A series of cookie settings provided by the server.
*/
public void setCookieSettings(Series<CookieSetting> cookieSettings) {
synchronized (getCookieSettings()) {
if (cookieSettings != getCookieSettings()) {
getCookieSettings().clear();
if (cookieSettings != null) {
getCookieSettings().addAll(cookieSettings);
}
}
}
}
/**
* Sets the set of dimensions on which the response entity may vary. Note
* that when used with HTTP connectors, this property maps to the "Vary"
* header. This method clears the current set and adds all entries in the
* parameter set.
*
* @param dimensions
* The set of dimensions on which the response entity may vary.
*/
public void setDimensions(Set<Dimension> dimensions) {
synchronized (getDimensions()) {
if (dimensions != getDimensions()) {
getDimensions().clear();
if (dimensions != null) {
getDimensions().addAll(dimensions);
}
}
}
}
/**
* Sets the reference that the client should follow for redirections or
* resource creations. Note that when used with HTTP connectors, this
* property maps to the "Location" header.
*
* @param locationRef
* The reference to set.
*/
public void setLocationRef(Reference locationRef) {
this.locationRef = locationRef;
}
/**
* Sets the reference that the client should follow for redirections or
* resource creations. If you pass a relative location URI, it will be
* resolved with the current base reference of the request's resource
* reference (see {@link Request#getResourceRef()} and
* {@link Reference#getBaseRef()}.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Location" header.
*
* @param locationUri
* The URI to set.
* @see #setLocationRef(Reference)
*/
public void setLocationRef(String locationUri) {
Reference baseRef = null;
if (getRequest().getResourceRef() != null) {
if (getRequest().getResourceRef().getBaseRef() != null) {
baseRef = getRequest().getResourceRef().getBaseRef();
} else {
baseRef = getRequest().getResourceRef();
}
}
setLocationRef(new Reference(baseRef, locationUri).getTargetRef());
}
/**
* Sets the modifiable list of authentication requests sent by a proxy to a
* client. The list instance set must be thread-safe (use
* {@link CopyOnWriteArrayList} for example. Note that when used with HTTP
* connectors, this property maps to the "Proxy-Authenticate" header. This
* method clears the current list and adds all entries in the parameter
* list.
*
* @param proxyChallengeRequests
* A list of authentication requests sent by a proxy to a client.
*/
public void setProxyChallengeRequests(
List<ChallengeRequest> proxyChallengeRequests) {
synchronized (getProxyChallengeRequests()) {
if (proxyChallengeRequests != getProxyChallengeRequests()) {
getProxyChallengeRequests().clear();
if (proxyChallengeRequests != null) {
getProxyChallengeRequests().addAll(proxyChallengeRequests);
}
}
}
}
/**
* Sets the associated request.
*
* @param request
* The associated request
*/
public void setRequest(Request request) {
this.request = request;
}
/**
* Indicates how long the service is expected to be unavailable to the
* requesting client. Default value is null.<br>
* <br>
* Note that when used with HTTP connectors, this property maps to the
* "Retry-After" header.
*
* @param retryAfter
* Date after with a retry attempt could occur.
*/
public void setRetryAfter(Date retryAfter) {
this.retryAfter = retryAfter;
}
/**
* Sets the server-specific information.
*
* @param serverInfo
* The server-specific information.
*/
public void setServerInfo(ServerInfo serverInfo) {
this.serverInfo = serverInfo;
}
/**
* Sets the status.
*
* @param status
* The status to set.
*/
public void setStatus(Status status) {
this.status = status;
}
/**
* Sets the status.
*
* @param status
* The status to set (code and reason phrase).
* @param description
* The longer status description.
*/
public void setStatus(Status status, String description) {
setStatus(new Status(status, description));
}
/**
* Sets the status.
*
* @param status
* The status to set.
* @param throwable
* The related error or exception.
*/
public void setStatus(Status status, Throwable throwable) {
setStatus(new Status(status, throwable));
}
/**
* Sets the status.
*
* @param status
* The status to set.
* @param throwable
* The related error or exception.
* @param message
* The status message.
*/
public void setStatus(Status status, Throwable throwable, String message) {
setStatus(new Status(status, throwable, message));
}
/**
* Displays a synthesis of the response like an HTTP status line.
*
* @return A synthesis of the response like an HTTP status line.
*/
public String toString() {
return ((getRequest() == null) ? "?" : getRequest().getProtocol())
+ " - " + getStatus();
}
}