Skip to content

Commit

Permalink
Digest fix for doorbird. (openhab#12399)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Skinner <matt@pcmus.com>
  • Loading branch information
Skinah authored and psmedley committed Feb 23, 2023
1 parent c31deb1 commit 27de517
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms
try {
if (msg instanceof HttpResponse) {
HttpResponse response = (HttpResponse) msg;
if (response.status().code() != 401) {
if (response.status().code() == 200) {
if (!response.headers().isEmpty()) {
for (String name : response.headers().names()) {
// Some cameras use first letter uppercase and others dont.
Expand Down Expand Up @@ -253,7 +253,7 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms
}
}
} else {
// 401 errors already handled in pipeline by MyNettyAuthHandler.java
// Non 200 OK replies are logged and handled in pipeline by MyNettyAuthHandler.java
return;
}
}
Expand Down Expand Up @@ -570,7 +570,7 @@ public void initChannel(SocketChannel socketChannel) throws Exception {
if (!"PUT".equals(httpMethod) || (useDigestAuth && digestString == null)) {
request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, new HttpMethod(httpMethod), httpRequestURL);
request.headers().set("Host", cameraConfig.getIp() + ":" + port);
request.headers().set("Connection", HttpHeaderValues.KEEP_ALIVE);
request.headers().set("Connection", HttpHeaderValues.CLOSE);
} else {
request = putRequestWithBody;
}
Expand Down Expand Up @@ -1648,7 +1648,8 @@ public void initialize() {
}

private void tryConnecting() {
if (!thing.getThingTypeUID().getId().equals(GENERIC_THING)) {
if (!thing.getThingTypeUID().getId().equals(GENERIC_THING)
&& !thing.getThingTypeUID().getId().equals(DOORBIRD_THING)) {
onvifCamera = new OnvifConnection(this, cameraConfig.getIp() + ":" + cameraConfig.getOnvifPort(),
cameraConfig.getUser(), cameraConfig.getPassword());
onvifCamera.setSelectedMediaProfile(cameraConfig.getOnvifMediaProfile());
Expand Down

0 comments on commit 27de517

Please sign in to comment.