public SearchResponse Search(OpenSubtitlesServiceParameters parameters) { var searchRequest = new[] { new SearchRequest { UserToken = LoginResponse.Token, LanguageId = parameters.Language, MovieHash = parameters.VideoFileHash } }; return _proxy.SearchSubtitles(searchRequest[0].UserToken, searchRequest); }
public static XmlRpc.XmlRpcResponse DoXmlRpcRequest(string url, XmlRpc.XmlRpcRequest req, int timeoutms, X509CertificateCollection clientCertificates = null) { byte[] rpcdata = req.Serialize(); using (Stream res = new HttpClient.Post(url, "text/xml", rpcdata.Length, (Stream s) => s.Write(rpcdata, 0, rpcdata.Length)) { TimeoutMs = timeoutms, ClientCertificates = clientCertificates }.ExecuteStreamRequest()) { return(XmlRpc.DeserializeResponse(res)); } }
private void RequestHandler(HttpRequest httpreq) { XmlRpc.XmlRpcRequest req; if (httpreq.Method != "POST") { httpreq.ErrorResponse(HttpStatusCode.MethodNotAllowed, "Method not allowed"); return; } try { req = XmlRpc.DeserializeRequest(httpreq.Body); } catch { FaultResponse(httpreq, -32700, "Invalid XML RPC Request"); return; } req.CallerIP = httpreq.CallerIP; req.IsSsl = httpreq.IsSsl; Func <XmlRpc.XmlRpcRequest, XmlRpc.XmlRpcResponse> del; Func <HttpRequest, XmlRpc.XmlRpcRequest, XmlRpc.XmlRpcResponse> del2; XmlRpc.XmlRpcResponse res; if (XmlRpcMethods_DiscThread.TryGetValue(req.MethodName, out del2)) { try { res = del2(httpreq, req); } catch (XmlRpc.XmlRpcFaultException e) { FaultResponse(httpreq, e.FaultCode, e.Message); return; } catch (Exception e) { m_Log.WarnFormat("Unexpected exception at XMRPC method {0}: {1}\n{2}", req.MethodName, e.GetType().Name, e.StackTrace); FaultResponse(httpreq, -32700, "Internal service error"); return; } if (res != null) { using (HttpResponse response = httpreq.BeginResponse()) { response.ContentType = "text/xml"; using (Stream o = response.GetOutputStream()) { res.Serialize(o); } } } else { throw new HttpResponse.DisconnectFromThreadException(); } } else if (XmlRpcMethods.TryGetValue(req.MethodName, out del)) { try { res = del(req); } catch (XmlRpc.XmlRpcFaultException e) { FaultResponse(httpreq, e.FaultCode, e.Message); return; } catch (Exception e) { m_Log.WarnFormat("Unexpected exception at XMRPC method {0}: {1}\n{2}", req.MethodName, e.GetType().Name, e.StackTrace); FaultResponse(httpreq, -32700, "Internal service error"); return; } using (HttpResponse response = httpreq.BeginResponse()) { response.ContentType = "text/xml"; using (Stream o = response.GetOutputStream()) { res.Serialize(o); } } } else { FaultResponse(httpreq, -32601, "Unknown Method"); } }
public bool Run() { XmlRpc.XmlRpcRequest req = XmlRpc.DeserializeRequest(new MemoryStream(UTF8NoBOM.GetBytes(ParserInput))); return(true); }