Skip to content

Commit 20d6a6d

Browse files
committed
fix(coap-core): add mapping for 204 http status to C205_CONTENT code
1 parent 4a7719b commit 20d6a6d

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ public static Code fromHttp(int httpStatus, Method method) {
130130
if (method == Method.DELETE) {
131131
return C202_DELETED;
132132
}
133+
if (method == Method.GET || method == Method.FETCH) {
134+
return C205_CONTENT;
135+
}
133136
return C204_CHANGED;
134137

135138

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
@@ -112,6 +112,7 @@ public void shouldConvertHttpToCoapCode() {
112112
assertEquals(Code.C201_CREATED, fromHttp(202, POST));
113113
assertEquals(Code.C202_DELETED, fromHttp(202, DELETE));
114114
assertEquals(Code.C202_DELETED, fromHttp(204, DELETE));
115+
assertEquals(Code.C205_CONTENT, fromHttp(204, GET));
115116

116117
assertEquals(Code.C203_VALID, fromHttp(304, GET));
117118

0 commit comments

Comments
 (0)