com.iteaj.iot.client.http.HttpResponseMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of iot-client Show documentation
Show all versions of iot-client Show documentation
基于netty的tcp, http, udp等协议的客户端
The newest version!
package com.iteaj.iot.client.http;
import com.iteaj.iot.client.ClientMessage;
import com.iteaj.iot.message.UnParseBodyMessage;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
public class HttpResponseMessage extends ClientMessage {
/**
* 标准http协议状态码
*/
private int code;
/**
* 响应报文
*/
private byte[] message;
/**
* 响应报文的 contentType
*/
private String contentType;
public HttpResponseMessage(int code, byte[] message, String contentType) {
super(new byte[]{});
this.code = code;
this.message = message;
this.contentType = contentType;
}
public int getCode() {
return code;
}
public String getMessage(String charset) {
try {
return new String(message, charset);
} catch (UnsupportedEncodingException e) {
throw new HttpProtocolException(e.getMessage(), e);
}
}
public String getContentType() {
return contentType;
}
public boolean isSuccessful() {
return code >= 200 && code < 300;
}
@Override
public int length() {
return this.message.length;
}
@Override
public byte[] getMessage() {
return message;
}
@Override
public MessageHead getHead() {
throw new UnsupportedOperationException("不支持的操作");
}
@Override
public MessageBody getBody() {
throw new UnsupportedOperationException("不支持的操作");
}
@Override
protected MessageHead doBuild(byte[] message) {
throw new UnsupportedOperationException("不支持的操作");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy