Commit 6d52561b authored by Björn Butzin's avatar Björn Butzin
Browse files

Bugfix: URI-PATH-Length

    URI-Path segments are now limited to 255 bytes (instead of 270)
    exception will be thrown if not (on client and server side)
parent 26a70237
......@@ -538,7 +538,7 @@ public abstract class AbstractCoapMessage implements CoapMessage {
int shortLength;
int longLength;
int deserializedLength;
static final int MAX_LENGTH = 270;
static final int MAX_LENGTH = 255;
public int getDeserializedLength() {
return deserializedLength;
......
......@@ -89,10 +89,6 @@ public class BasicCoapRequest extends AbstractCoapMessage implements CoapRequest
public void setUriPath(String path) {
if (path == null) return;
// if (path.length() > CoapHeaderOption.MAX_LENGTH ){
// throw new IllegalArgumentException("Uri-Path option too long");
// }
/* delete old options if present */
options.removeOption(CoapHeaderOptionType.Uri_Path);
......
......@@ -50,11 +50,18 @@ public class BasicCoapResource implements CoapResource {
Boolean reliableNotification = null;
/**
* The Unix time (in milliseconds), when resource expires
* The Unix time (in milliseconds), when resource expires<br>
* -1, when resource never expires */
long expires = -1;
public BasicCoapResource(String path, byte[] value, CoapMediaType mediaType) {
path = path.trim();
String[] segments = path.split("/");
for(String segment : segments){
if(segment.getBytes().length > 255 ){
throw new IllegalArgumentException("Uri-Path too long");
}
}
this.path = path;
this.value = value;
this.mediaType = mediaType;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment