Skip to content

Commit d3512fe

Browse files
committed
Update WebService.
1 parent 71a8263 commit d3512fe

5 files changed

Lines changed: 61 additions & 91 deletions

File tree

kilo-server/src/main/java/org/httprpc/kilo/WebService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,9 +1055,9 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
10551055
request.setCharacterEncoding(StandardCharsets.UTF_8.name());
10561056
}
10571057

1058-
var contentType = map(request.getContentType(), value -> value.substring(0, value.indexOf(";")).trim().toLowerCase());
1058+
var contentType = map(request.getContentType(), value -> value.split(";")[0].trim().toLowerCase());
10591059

1060-
var formData = contentType.equals(APPLICATION_X_WWW_FORM_URLENCODED) || contentType.equals(MULTIPART_FORM_DATA);
1060+
var formData = contentType != null && (contentType.equals(APPLICATION_X_WWW_FORM_URLENCODED) || contentType.equals(MULTIPART_FORM_DATA));
10611061

10621062
var handler = getHandler(request, handlerList, keys.size(), formData);
10631063

kilo-test/src/main/java/org/httprpc/kilo/test/TestService.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import java.util.SequencedMap;
4848
import java.util.SequencedSet;
4949
import java.util.Set;
50-
import java.util.SortedSet;
5150
import java.util.UUID;
5251

5352
import static org.httprpc.kilo.util.Collections.*;
@@ -102,8 +101,6 @@ public interface Response {
102101
List<String> getStrings();
103102
Integer getNumber();
104103
Set<Integer> getNumbers();
105-
char getCharacter();
106-
Set<Character> getCharacters();
107104
boolean getFlag();
108105
DayOfWeek getDayOfWeek();
109106
Instant getDate();
@@ -195,7 +192,7 @@ public Number next() {
195192

196193
@RequestMethod("GET")
197194
public Response testGet(@Required String string, List<String> strings,
198-
int number, SequencedSet<Integer> numbers, char character, SortedSet<Character> characters,
195+
int number, SequencedSet<Integer> numbers,
199196
boolean flag, DayOfWeek dayOfWeek,
200197
Instant date, List<Instant> dates,
201198
LocalDate localDate, LocalTime localTime, LocalDateTime localDateTime,
@@ -206,8 +203,6 @@ public Response testGet(@Required String string, List<String> strings,
206203
entry("strings", strings),
207204
entry("number", number),
208205
entry("numbers", numbers),
209-
entry("character", character),
210-
entry("characters", characters),
211206
entry("flag", flag),
212207
entry("dayOfWeek", dayOfWeek),
213208
entry("date", date),

kilo-test/src/test/java/org/httprpc/kilo/test/TestServiceProxy.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.List;
3333
import java.util.Map;
3434
import java.util.SequencedSet;
35-
import java.util.SortedSet;
3635

3736
import static org.httprpc.kilo.util.Iterables.*;
3837

@@ -75,7 +74,7 @@ public void handleResponse(InputStream errorStream, String contentType, int stat
7574

7675
@RequestMethod("GET")
7776
TestService.Response testGet(@Required String string, List<String> strings,
78-
int number, SequencedSet<Integer> numbers, char character, SortedSet<Character> characters,
77+
int number, SequencedSet<Integer> numbers,
7978
boolean flag) throws IOException;
8079

8180
@RequestMethod("GET")

kilo-test/src/test/java/org/httprpc/kilo/test/WebServiceProxyTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ public void testGet() throws IOException {
7676
entry("strings", listOf("a", "b", "c")),
7777
entry("number", 123),
7878
entry("numbers", listOf(1, 2, 2, 3, 3, 3)),
79-
entry("character", "abc"),
80-
entry("characters", listOf('c', 'b', 'b', 'a', 'a', 'a')),
8179
entry("flag", true),
8280
entry("dayOfWeek", dayOfWeek),
8381
entry("date", date),
@@ -98,8 +96,6 @@ public void testGet() throws IOException {
9896
assertEquals(listOf("a", "b", "c"), result.getStrings());
9997
assertEquals(123, result.getNumber());
10098
assertEquals(setOf(1, 2, 3), result.getNumbers());
101-
assertEquals('a', result.getCharacter());
102-
assertEquals(sortedSetOf('a', 'b', 'c'), result.getCharacters());
10399
assertTrue(result.getFlag());
104100
assertEquals(dayOfWeek, result.getDayOfWeek());
105101
assertEquals(date, result.getDate());
@@ -117,15 +113,13 @@ public void testGetProxy() throws IOException {
117113
var testServiceProxy = WebServiceProxy.of(TestServiceProxy.class, baseURI);
118114

119115
var result = testServiceProxy.testGet("héllo&gøod+bye?", listOf("a", "b", "c"),
120-
123, setOf(1, 2, 3), 'a', sortedSetOf('a', 'b', 'c'),
116+
123, setOf(1, 2, 3),
121117
true);
122118

123119
assertEquals("héllo&gøod+bye?", result.getString());
124120
assertEquals(listOf("a", "b", "c"), result.getStrings());
125121
assertEquals(123, result.getNumber());
126122
assertEquals(setOf(1, 2, 3), result.getNumbers());
127-
assertEquals('a', result.getCharacter());
128-
assertEquals(sortedSetOf('a', 'b', 'c'), result.getCharacters());
129123
assertTrue(result.getFlag());
130124
}
131125

@@ -623,7 +617,7 @@ public void testMissingRequiredParameter() {
623617
public void testMissingRequiredParameterProxy() {
624618
var testServiceProxy = WebServiceProxy.of(TestServiceProxy.class, baseURI);
625619

626-
assertThrows(IllegalArgumentException.class, () -> testServiceProxy.testGet(null, null, 0, null, '\0', null, false));
620+
assertThrows(IllegalArgumentException.class, () -> testServiceProxy.testGet(null, null, 0, null, false));
627621
}
628622

629623
@Test

kilo-test/src/test/resources/org/httprpc/kilo/test/api/test.html

Lines changed: 55 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,14 @@
239239
<!-- -->
240240
<li><a href="#DayOfWeek">DayOfWeek</a></li>
241241
<!-- -->
242-
<li><a href="#TestService.TestEnum">TestService.TestEnum</a></li>
242+
<li><a href="#TestService.TestRecord.TestEnum">TestService.TestRecord.TestEnum</a></li>
243243
<!-- -->
244244
</ol>
245245
</li>
246246
<!-- -->
247247
<!-- -->
248248
<li><a href="#structures">Structures</a>
249249
<ol>
250-
<!-- -->
251-
<li><a href="#Character">Character</a></li>
252250
<!-- -->
253251
<li><a href="#Coordinates">Coordinates</a></li>
254252
<!-- -->
@@ -264,6 +262,8 @@
264262
<!-- -->
265263
<li><a href="#TestService.E">TestService.E</a></li>
266264
<!-- -->
265+
<li><a href="#TestService.FormContents">TestService.FormContents</a></li>
266+
<!-- -->
267267
<li><a href="#TestService.Response">TestService.Response</a></li>
268268
<!-- -->
269269
<li><a href="#TestService.TestRecord">TestService.TestRecord</a></li>
@@ -320,18 +320,6 @@ <h2><code>/test</code></h2>
320320
<td></td>
321321
</tr>
322322
<!-- -->
323-
<tr>
324-
<td><code>character</code></td>
325-
<td><code>char</code></td>
326-
<td></td>
327-
</tr>
328-
<!-- -->
329-
<tr>
330-
<td><code>characters</code></td>
331-
<td><code>[<a href="#Character">Character</a>]</code></td>
332-
<td></td>
333-
</tr>
334-
<!-- -->
335323
<tr>
336324
<td><code>flag</code></td>
337325
<td><code>boolean</code></td>
@@ -872,38 +860,8 @@ <h2><code>/test/form-data</code></h2>
872860
<tbody>
873861
<!-- -->
874862
<tr>
875-
<td><code>string</code></td>
876-
<td><code>String&nbsp;•</code></td>
877-
<td></td>
878-
</tr>
879-
<!-- -->
880-
<tr>
881-
<td><code>strings</code></td>
882-
<td><code>[String]</code></td>
883-
<td></td>
884-
</tr>
885-
<!-- -->
886-
<tr>
887-
<td><code>number</code></td>
888-
<td><code>Integer</code></td>
889-
<td></td>
890-
</tr>
891-
<!-- -->
892-
<tr>
893-
<td><code>date</code></td>
894-
<td><code>Instant</code></td>
895-
<td></td>
896-
</tr>
897-
<!-- -->
898-
<tr>
899-
<td><code>file</code></td>
900-
<td><code>Part</code></td>
901-
<td></td>
902-
</tr>
903-
<!-- -->
904-
<tr>
905-
<td><code>files</code></td>
906-
<td><code>[Part]</code></td>
863+
<td><code>formContents</code></td>
864+
<td><code><a href="#TestService.FormContents">TestService.FormContents</a></code></td>
907865
<td></td>
908866
</tr>
909867
<!-- -->
@@ -1247,8 +1205,8 @@ <h2><a id="DayOfWeek">DayOfWeek</a></h2>
12471205
</table>
12481206
</section>
12491207
<!-- -->
1250-
<section id="TestService.TestEnum">
1251-
<h2><a id="TestService.TestEnum">TestService.TestEnum</a></h2>
1208+
<section id="TestService.TestRecord.TestEnum">
1209+
<h2><a id="TestService.TestRecord.TestEnum">TestService.TestRecord.TestEnum</a></h2>
12521210
<!-- -->
12531211
<table>
12541212
<thead>
@@ -1284,23 +1242,6 @@ <h2><a id="TestService.TestEnum">TestService.TestEnum</a></h2>
12841242
<div id="structures">
12851243
<h1>Structures</h1>
12861244
<!-- -->
1287-
<section id="Character">
1288-
<h2><a id="Character">Character</a></span></h2>
1289-
<!-- -->
1290-
<table>
1291-
<thead>
1292-
<tr>
1293-
<th>Property</th>
1294-
<th>Type</th>
1295-
<th>Description</th>
1296-
</tr>
1297-
</thead>
1298-
<tbody>
1299-
<!-- -->
1300-
</tbody>
1301-
</table>
1302-
</section>
1303-
<!-- -->
13041245
<section id="Coordinates">
13051246
<h2><a id="Coordinates">Coordinates</a></span></h2>
13061247
<!-- -->
@@ -1500,8 +1441,8 @@ <h2><a id="TestService.E">TestService.E</a> : <span class="supertypes"><a href="
15001441
</table>
15011442
</section>
15021443
<!-- -->
1503-
<section id="TestService.Response">
1504-
<h2><a id="TestService.Response">TestService.Response</a></span></h2>
1444+
<section id="TestService.FormContents">
1445+
<h2><a id="TestService.FormContents">TestService.FormContents</a></span></h2>
15051446
<!-- -->
15061447
<table>
15071448
<thead>
@@ -1514,17 +1455,58 @@ <h2><a id="TestService.Response">TestService.Response</a></span></h2>
15141455
<tbody>
15151456
<!-- -->
15161457
<tr>
1517-
<td><code>character</code></td>
1518-
<td><code>char</code></td>
1458+
<td><code>string</code></td>
1459+
<td><code>String&nbsp;•</code></td>
1460+
<td></td>
1461+
</tr>
1462+
<!-- -->
1463+
<tr>
1464+
<td><code>strings</code></td>
1465+
<td><code>[String]</code></td>
1466+
<td></td>
1467+
</tr>
1468+
<!-- -->
1469+
<tr>
1470+
<td><code>number</code></td>
1471+
<td><code>Integer</code></td>
1472+
<td></td>
1473+
</tr>
1474+
<!-- -->
1475+
<tr>
1476+
<td><code>date</code></td>
1477+
<td><code>Instant</code></td>
15191478
<td></td>
15201479
</tr>
15211480
<!-- -->
15221481
<tr>
1523-
<td><code>characters</code></td>
1524-
<td><code>[<a href="#Character">Character</a>]</code></td>
1482+
<td><code>file</code></td>
1483+
<td><code>Path</code></td>
15251484
<td></td>
15261485
</tr>
15271486
<!-- -->
1487+
<tr>
1488+
<td><code>files</code></td>
1489+
<td><code>[Path]</code></td>
1490+
<td></td>
1491+
</tr>
1492+
<!-- -->
1493+
</tbody>
1494+
</table>
1495+
</section>
1496+
<!-- -->
1497+
<section id="TestService.Response">
1498+
<h2><a id="TestService.Response">TestService.Response</a></span></h2>
1499+
<!-- -->
1500+
<table>
1501+
<thead>
1502+
<tr>
1503+
<th>Property</th>
1504+
<th>Type</th>
1505+
<th>Description</th>
1506+
</tr>
1507+
</thead>
1508+
<tbody>
1509+
<!-- -->
15281510
<tr>
15291511
<td><code>date</code></td>
15301512
<td><code>Instant</code></td>
@@ -1634,7 +1616,7 @@ <h2><a id="TestService.TestRecord">TestService.TestRecord</a></span></h2>
16341616
<!-- -->
16351617
<tr>
16361618
<td><code><s>testEnum</s></code></td>
1637-
<td><code><a href="#TestService.TestEnum">TestService.TestEnum</a></code></td>
1619+
<td><code><a href="#TestService.TestRecord.TestEnum">TestService.TestRecord.TestEnum</a></code></td>
16381620
<td></td>
16391621
</tr>
16401622
<!-- -->

0 commit comments

Comments
 (0)