Skip to content

Commit 3ba81a2

Browse files
committed
fix(coap-core): fix 202 http status mapping to coap code
1 parent 9760b47 commit 3ba81a2

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

coap-core/src/main/java/com/mbed/coap/packet/Code.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public static Code fromHttp(int httpStatus, Method method) {
111111
switch (httpStatus) {
112112
// SUCCESS (2.xx)
113113
case 200:
114+
case 202: // Closest semantic match is to use same code as 200
114115
switch (method) {
115116
case PUT:
116117
case POST:
@@ -124,8 +125,6 @@ public static Code fromHttp(int httpStatus, Method method) {
124125
}
125126
case 201:
126127
return C201_CREATED;
127-
case 202:
128-
return C204_CHANGED; // Closest semantic match
129128
case 204:
130129
if (method == Method.DELETE) {
131130
return C202_DELETED;

coap-core/src/test/java/com/mbed/coap/packet/CodeTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public void shouldConvertHttpToCoapCode() {
109109
assertEquals(Code.C202_DELETED, fromHttp(200, DELETE));
110110
assertEquals(Code.C201_CREATED, fromHttp(201, POST));
111111
assertEquals(Code.C204_CHANGED, fromHttp(202, POST));
112+
assertEquals(Code.C202_DELETED, fromHttp(202, DELETE));
112113
assertEquals(Code.C202_DELETED, fromHttp(204, DELETE));
113114

114115
assertEquals(Code.C203_VALID, fromHttp(304, GET));

0 commit comments

Comments
 (0)