@@ -73,22 +73,38 @@ public final class HttpOpener extends DefaultObjectPipe<String, ObjectReceiver<R
73
73
74
74
public enum Method {
75
75
76
- DELETE (false ),
77
- GET (false ),
78
- HEAD (false ),
79
- OPTIONS (false ),
80
- POST (true ),
81
- PUT (true ),
82
- TRACE (false );
83
-
84
- private final boolean inputAsBody ;
85
-
86
- Method (final boolean inputAsBody ) {
87
- this .inputAsBody = inputAsBody ;
76
+ DELETE (false , true ),
77
+ GET (false , true ),
78
+ HEAD (false , false ),
79
+ OPTIONS (false , true ),
80
+ POST (true , true ),
81
+ PUT (true , true ),
82
+ TRACE (false , true );
83
+
84
+ private final boolean requestHasBody ;
85
+ private final boolean responseHasBody ;
86
+
87
+ Method (final boolean requestHasBody , final boolean responseHasBody ) {
88
+ this .requestHasBody = requestHasBody ;
89
+ this .responseHasBody = responseHasBody ;
88
90
}
89
91
90
- private boolean getInputAsBody () {
91
- return inputAsBody ;
92
+ /**
93
+ * Checks whether the request method accepts a request body.
94
+ *
95
+ * @return true if the request method accepts a request body
96
+ */
97
+ public boolean getRequestHasBody () {
98
+ return requestHasBody ;
99
+ }
100
+
101
+ /**
102
+ * Checks whether the request method returns a response body.
103
+ *
104
+ * @return true if the request method returns a response body
105
+ */
106
+ public boolean getResponseHasBody () {
107
+ return responseHasBody ;
92
108
}
93
109
94
110
}
@@ -207,7 +223,7 @@ public void process(final String input) {
207
223
try {
208
224
final String requestUrl = getInput (input , url );
209
225
final String requestBody = getInput (input ,
210
- body == null && method .getInputAsBody () ? INPUT_DESIGNATOR : body );
226
+ body == null && method .getRequestHasBody () ? INPUT_DESIGNATOR : body );
211
227
212
228
final HttpURLConnection connection =
213
229
(HttpURLConnection ) new URL (requestUrl ).openConnection ();
0 commit comments