コード例 #1
0
        /// <summary>
        /// Invokes the request, receives/formats response and returns it to the caller
        /// </summary>
        /// <param name="method">The method representing the action</param>
        /// <param name="parameters">The parameters to pass in the request</param>
        /// <returns></returns>
        object IDynamicContract.InvokeFunction(MethodInfo method, object[] parameters)
        {
            var spec    = Specify(method, parameters);
            var outcome = Channel.Send(spec);

            return(Interpret(outcome));;
        }
コード例 #2
0
        private void Send()
        {
            const string eol           = "\r\n";
            var          contentLength = _body.Length;

            var sb = new StringBuilder();

            sb.Append("HTTP/1.1 " + StatusCode + " " + HttpWorkerRequest.GetStatusDescription(StatusCode) + eol);
            sb.Append("Server: Express/" + AssemblyInfo.Version + eol);
            sb.Append("Date: " + DateTime.Now.ToUniversalTime().ToString("R", DateTimeFormatInfo.InvariantInfo) + eol);

            if (contentLength >= 0)
            {
                sb.Append("Content-Length: " + contentLength + eol);
            }

            foreach (string key in _headers)
            {
                var val = _headers[key];
                sb.Append(key + ": " + val + eol);
            }

            sb.Append(eol);

            var header = Encoding.UTF8.GetBytes(sb.ToString());

            _output.Flush();
            _body.Flush();
            var body = _body.ToArray();

            try
            {
                _channel.Send(header.Concat(body).ToArray());
            }
            catch (Exception)
            {
            }
        }