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 package org.apache.hc.core5.http.impl.nio;
29
30 import org.apache.hc.core5.annotation.Contract;
31 import org.apache.hc.core5.annotation.ThreadingBehavior;
32 import org.apache.hc.core5.http.HttpResponse;
33 import org.apache.hc.core5.http.message.BasicLineFormatter;
34 import org.apache.hc.core5.http.message.LineFormatter;
35 import org.apache.hc.core5.http.nio.NHttpMessageWriter;
36 import org.apache.hc.core5.http.nio.NHttpMessageWriterFactory;
37
38
39
40
41
42
43 @Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
44 public class DefaultHttpResponseWriterFactory implements NHttpMessageWriterFactory<HttpResponse> {
45
46 public static final DefaultHttpResponseWriterFactorysponseWriterFactory.html#DefaultHttpResponseWriterFactory">DefaultHttpResponseWriterFactory INSTANCE = new DefaultHttpResponseWriterFactory();
47
48 private final LineFormatter lineFormatter;
49
50 public DefaultHttpResponseWriterFactory(final LineFormatter lineFormatter) {
51 super();
52 this.lineFormatter = lineFormatter != null ? lineFormatter : BasicLineFormatter.INSTANCE;
53 }
54
55 public DefaultHttpResponseWriterFactory() {
56 this(null);
57 }
58
59 @Override
60 public NHttpMessageWriter<HttpResponse> create() {
61 return new DefaultHttpResponseWriter<>(this.lineFormatter);
62 }
63
64 }