* save loads of bandwith simply by enabling gzip compression for xmlrpc requests :D
@see http://forum.opensubtitles.org/viewtopic.php?f=8&t=14246#p27901
This commit is contained in:
parent
2fa1ca6dc2
commit
ae57b4e541
|
@ -5,6 +5,7 @@ import static net.sourceforge.tuned.StringUtilities.*;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -22,6 +23,7 @@ import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.DeflaterInputStream;
|
import java.util.zip.DeflaterInputStream;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
import net.sourceforge.filebot.web.OpenSubtitlesSubtitleDescriptor.Property;
|
import net.sourceforge.filebot.web.OpenSubtitlesSubtitleDescriptor.Property;
|
||||||
import net.sourceforge.tuned.ByteBufferOutputStream;
|
import net.sourceforge.tuned.ByteBufferOutputStream;
|
||||||
|
@ -300,7 +302,16 @@ public class OpenSubtitlesXmlRpc {
|
||||||
|
|
||||||
protected Map<?, ?> invoke(String method, Object... arguments) throws XmlRpcFault {
|
protected Map<?, ?> invoke(String method, Object... arguments) throws XmlRpcFault {
|
||||||
try {
|
try {
|
||||||
XmlRpcClient rpc = new XmlRpcClient(getXmlRpcUrl(), false);
|
XmlRpcClient rpc = new XmlRpcClient(getXmlRpcUrl(), false) {
|
||||||
|
public void parse(InputStream input) throws XmlRpcException {
|
||||||
|
try {
|
||||||
|
super.parse(new GZIPInputStream(input));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new XmlRpcException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
rpc.setRequestProperty("Accept-Encoding", "gzip");
|
||||||
|
|
||||||
Map<?, ?> response = (Map<?, ?>) rpc.invoke(method, arguments);
|
Map<?, ?> response = (Map<?, ?>) rpc.invoke(method, arguments);
|
||||||
checkResponse(response);
|
checkResponse(response);
|
||||||
|
|
Loading…
Reference in New Issue