67 }
68
69 static final int LF = 10;
70 static final int CR = 13;
71
72 private boolean chunkedContent, chunkedContentInitialized;
73
74 boolean contentChunked() throws IOException {
75 if (chunkedContentInitialized) {
76 return chunkedContent;
77 }
78 if (contentLength == -2) {
79 // HTTP/1.0 content
80 chunkedContentInitialized = true;
81 chunkedContent = false;
82 return chunkedContent;
83 }
84 if (contentLength == -1) {
85 String tc = headers.firstValue("Transfer-Encoding")
86 .orElse("");
87 if (!tc.equals("")) {
88 if (tc.equalsIgnoreCase("chunked")) {
89 chunkedContent = true;
90 } else {
91 throw new IOException("invalid content");
92 }
93 } else {
94 chunkedContent = false;
95 }
96 }
97 chunkedContentInitialized = true;
98 return chunkedContent;
99 }
100
101 interface BodyParser extends Consumer<ByteBuffer> {
102 void onSubscribe(AbstractSubscription sub);
103 // A current-state message suitable for inclusion in an exception
104 // detail message.
105 String currentStateMessage();
106 }
107
|
67 }
68
69 static final int LF = 10;
70 static final int CR = 13;
71
72 private boolean chunkedContent, chunkedContentInitialized;
73
74 boolean contentChunked() throws IOException {
75 if (chunkedContentInitialized) {
76 return chunkedContent;
77 }
78 if (contentLength == -2) {
79 // HTTP/1.0 content
80 chunkedContentInitialized = true;
81 chunkedContent = false;
82 return chunkedContent;
83 }
84 if (contentLength == -1) {
85 String tc = headers.firstValue("Transfer-Encoding")
86 .orElse("");
87 if (!tc.isEmpty()) {
88 if (tc.equalsIgnoreCase("chunked")) {
89 chunkedContent = true;
90 } else {
91 throw new IOException("invalid content");
92 }
93 } else {
94 chunkedContent = false;
95 }
96 }
97 chunkedContentInitialized = true;
98 return chunkedContent;
99 }
100
101 interface BodyParser extends Consumer<ByteBuffer> {
102 void onSubscribe(AbstractSubscription sub);
103 // A current-state message suitable for inclusion in an exception
104 // detail message.
105 String currentStateMessage();
106 }
107
|