Mono.FastCgi.Connection.EndRequest C# (CSharp) Метод

EndRequest() публичный Метод

public EndRequest ( ushort requestID, int appStatus, ProtocolStatus protocolStatus ) : void
requestID ushort
appStatus int
protocolStatus ProtocolStatus
Результат void
        public void EndRequest(ushort requestID, int appStatus,
		                        ProtocolStatus protocolStatus)
        {
            EndRequestBody body = new EndRequestBody (appStatus,
                protocolStatus);
            try {
                if (IsConnected)
                    new Record (1, RecordType.EndRequest, requestID,
                            body.GetData ()).Send (socket);
            } catch (System.Net.Sockets.SocketException) {
            }

            int index = GetRequestIndex (requestID);

            if (index >= 0) {
                lock (request_lock) {
                    requests.RemoveAt (index);
                }
            }

            lock (connection_teardown_lock) {
                if (requests.Count == 0 && (!keep_alive || stop)) {
                    if (socket != null) {
                        try {
                            socket.Close ();
                        } finally {
                            socket = null;
                        }
                    }

                    if (!stop)
                        server.EndConnection (this);
                    if (receive_buffer != null && send_buffer != null) {
                        server.ReleaseBuffers (receive_buffer, send_buffer);
                        receive_buffer = null;
                        send_buffer = null;
                    }
                }
            }
        }

Usage Example

Пример #1
0
        // When a request is completed, the output and error streams
        // must be completed and the final farewell must be send so
        // the HTTP server can finish its response.

        public void CompleteRequest(int appStatus,
                                    ProtocolStatus protocolStatus)
        {
            // Data is no longer needed.
            DataNeeded = false;

            // Close the standard output if it was opened.
            if (stdout_sent)
            {
                SendStreamData(RecordType.StandardOutput,
                               new byte [0], 0);
            }

            // Close the standard error if it was opened.
            if (stderr_sent)
            {
                SendStreamData(RecordType.StandardError,
                               new byte [0], 0);
            }

            connection.EndRequest(RequestID, appStatus,
                                  protocolStatus);
        }