mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Fixed MQTT initialization error with maven build inclusion. Added URI
encoder to handle URI calls with URL characters. Fixes #250 Fixes #251 Fixes #252
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.5.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
@@ -192,6 +192,12 @@
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>org.eclipse.paho:org.eclipse.paho.client.mqttv3</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
<transformers>
|
||||
<transformer
|
||||
|
||||
@@ -66,6 +66,8 @@ import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -1125,6 +1127,7 @@ public class HueMulator implements HueErrorStringSet {
|
||||
protected String doHttpRequest(String url, String httpVerb, String contentType, String body, NameValue[] headers) {
|
||||
HttpUriRequest request = null;
|
||||
String theContent = null;
|
||||
URI theURI = null;
|
||||
ContentType parsedContentType = null;
|
||||
StringEntity requestBody = null;
|
||||
if(contentType != null && contentType.length() > 0) {
|
||||
@@ -1132,17 +1135,22 @@ public class HueMulator implements HueErrorStringSet {
|
||||
if(body != null && body.length() > 0)
|
||||
requestBody = new StringEntity(body, parsedContentType);
|
||||
}
|
||||
|
||||
try {
|
||||
theURI = new URI(url);
|
||||
} catch (URISyntaxException e1) {
|
||||
log.warn("Error creating URI http request: " + url + " with message: " + e1.getMessage());
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if(HttpGet.METHOD_NAME.equalsIgnoreCase(httpVerb) || httpVerb == null) {
|
||||
request = new HttpGet(url);
|
||||
request = new HttpGet(theURI);
|
||||
}else if(HttpPost.METHOD_NAME.equalsIgnoreCase(httpVerb)){
|
||||
HttpPost postRequest = new HttpPost(url);
|
||||
HttpPost postRequest = new HttpPost(theURI);
|
||||
if(requestBody != null)
|
||||
postRequest.setEntity(requestBody);
|
||||
request = postRequest;
|
||||
}else if(HttpPut.METHOD_NAME.equalsIgnoreCase(httpVerb)){
|
||||
HttpPut putRequest = new HttpPut(url);
|
||||
HttpPut putRequest = new HttpPut(theURI);
|
||||
if(requestBody != null)
|
||||
putRequest.setEntity(requestBody);
|
||||
request = putRequest;
|
||||
|
||||
Reference in New Issue
Block a user