2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.enigma2.internal;
15 import java.io.IOException;
16 import java.util.regex.Pattern;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.io.net.http.HttpUtil;
22 * The {@link Enigma2HttpClient} class is responsible for sending HTTP-Get requests to the Enigma2 device.
23 * It is devided from {@link Enigma2Client} for better testing purpose.
25 * @author Guido Dolfen - Initial contribution
28 public class Enigma2HttpClient {
29 public static final Pattern PATTERN = Pattern
30 .compile("[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD\\u10000-\\u10FFF]+");
31 private final int timeout;
33 public Enigma2HttpClient(int timeout) {
34 this.timeout = timeout;
37 public String get(String url) throws IOException, IllegalArgumentException {
38 String xml = HttpUtil.executeUrl("GET", url, timeout * 1000);
39 // remove some unsupported xml-characters
40 return PATTERN.matcher(xml).replaceAll("");