示例#1
0
        // Attempt to write the response over the wire to the client
        private static void ProcessResponse(ICouchbaseListenerContext context, ICouchbaseResponseState responseState)
        {
            CouchbaseLiteResponse responseObject = CheckForAltMethod(context, responseState.Response);

            if (!responseState.IsAsync)
            {
                try {
                    Log.To.Router.I(TAG, "Processing response for {0}...", context.RequestUrl.PathAndQuery);
                    Log.To.Router.V(TAG, "Processing request range...");
                    responseObject.ProcessRequestRanges();
                    Log.To.Router.V(TAG, "Writing headers...");
                    responseObject.WriteHeaders();
                    Log.To.Router.V(TAG, "Writing body...");
                    responseObject.WriteToContext();
                    Log.To.Router.I(TAG, "{0} {1} => {2} ({3})", context.Method, context.RequestUrl.PathAndQuery, responseObject.Status, responseObject.StatusMessage);
                } catch (Exception e) {
                    Log.To.Router.E(TAG, "Exception writing response", e);
                    responseState = context.CreateResponse(StatusCode.Exception).AsDefaultState();
                }
            }
            else
            {
                _UnfinishedResponses.Add(responseState);
            }
        }
示例#2
0
        // Attempt to write the response over the wire to the client
        private static void ProcessResponse(ICouchbaseListenerContext context, ICouchbaseResponseState responseState)
        {
            CouchbaseLiteResponse responseObject = CheckForAltMethod(context, responseState.Response);

            if (!responseState.IsAsync)
            {
                try {
                    responseObject.ProcessRequestRanges();
                    responseObject.WriteHeaders();
                    responseObject.WriteToContext();
                } catch (Exception e) {
                    Log.E(TAG, "Exception writing response", e);
                    responseState = context.CreateResponse(StatusCode.Exception).AsDefaultState();
                }
            }
            else
            {
                _UnfinishedResponses.Add(responseState);
            }
        }