Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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));
     }
 }
Esempio n. 3
0
        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");
            }
        }
Esempio n. 4
0
 public bool Run()
 {
     XmlRpc.XmlRpcRequest req = XmlRpc.DeserializeRequest(new MemoryStream(UTF8NoBOM.GetBytes(ParserInput)));
     return(true);
 }