mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
Handle HTTP 404 File Not Found response correctly
This commit is contained in:
parent
c9bbdf5e65
commit
1868e9eb06
@ -17,6 +17,9 @@ public class JsonUtilities {
|
||||
public static final Object[] EMPTY_ARRAY = new Object[0];
|
||||
|
||||
public static Object readJson(CharSequence json) {
|
||||
if (json.length() == 0) {
|
||||
return EMPTY_MAP;
|
||||
}
|
||||
return JsonReader.jsonToJava(json.toString(), singletonMap(JsonReader.USE_MAPS, true));
|
||||
}
|
||||
|
||||
|
@ -78,29 +78,28 @@ public final class WebRequest {
|
||||
return new InputStreamReader(inputStream, charset);
|
||||
}
|
||||
|
||||
public static Document getDocument(URL url) throws IOException, SAXException {
|
||||
public static Document getDocument(URL url) throws Exception {
|
||||
return getDocument(url.openConnection());
|
||||
}
|
||||
|
||||
public static Document getDocument(URLConnection connection) throws IOException, SAXException {
|
||||
public static Document getDocument(URLConnection connection) throws Exception {
|
||||
return getDocument(new InputSource(getReader(connection)));
|
||||
}
|
||||
|
||||
public static Document getDocument(String xml) throws IOException, SAXException {
|
||||
public static Document getDocument(String xml) throws Exception {
|
||||
if (xml.isEmpty()) {
|
||||
return DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||
}
|
||||
|
||||
return getDocument(new InputSource(new StringReader(xml)));
|
||||
}
|
||||
|
||||
public static Document getDocument(InputSource source) throws IOException, SAXException {
|
||||
try {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setFeature("http://xml.org/sax/features/namespaces", false);
|
||||
factory.setFeature("http://xml.org/sax/features/validation", false);
|
||||
return factory.newDocumentBuilder().parse(source);
|
||||
} catch (ParserConfigurationException e) {
|
||||
// will never happen
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public static Document getDocument(InputSource source) throws Exception {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setFeature("http://xml.org/sax/features/namespaces", false);
|
||||
factory.setFeature("http://xml.org/sax/features/validation", false);
|
||||
return factory.newDocumentBuilder().parse(source);
|
||||
}
|
||||
|
||||
public static ByteBuffer fetch(URL resource) throws IOException {
|
||||
@ -311,6 +310,9 @@ public final class WebRequest {
|
||||
}
|
||||
|
||||
public static void validateXml(String xml) throws SAXException, ParserConfigurationException, IOException {
|
||||
if (xml.isEmpty())
|
||||
return;
|
||||
|
||||
SAXParserFactory sax = SAXParserFactory.newInstance();
|
||||
sax.setValidating(false);
|
||||
sax.setNamespaceAware(false);
|
||||
|
Loading…
Reference in New Issue
Block a user