From: Vlad S. <ser...@us...> - 2005-03-05 23:28:35
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1286/nsd Modified Files: conn.c Log Message: Add Ns_ConnSetResponseStatus command to be able to se response status without touching headers. Also ns_conn status has been extended with ability to set response status if third argument is provided. ns_conn status ?newStatus? Index: conn.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/conn.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** conn.c 16 Feb 2005 08:39:44 -0000 1.1.1.1 --- conn.c 5 Mar 2005 23:28:25 -0000 1.2 *************** *** 234,237 **** --- 234,262 ---- } + /* + *---------------------------------------------------------------------- + * + * Ns_ConnSetResponseStatus -- + * + * Set the HTTP reponse code that will be sent + * + * Results: + * Previous response status as an integer response code (e.g., 200 for OK) + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + + int + Ns_ConnSetResponseStatus(Ns_Conn *conn, int new_status) + { + Conn *connPtr = (Conn *) conn; + + connPtr->responseStatus = new_status; + return new_status; + } + /* *************** *** 809,813 **** FormFile *filePtr; int idx, off, len; - int write_encoded_flag; static CONST char *opts[] = { --- 834,837 ---- *************** *** 1040,1044 **** case CWriteEncodedIdx: if (objc > 2) { ! if (Tcl_GetIntFromObj(interp, objv[2], &write_encoded_flag) != TCL_OK) { Tcl_AppendResult(interp, "Invalid write-encoded flag", NULL ); --- 1064,1069 ---- case CWriteEncodedIdx: if (objc > 2) { ! int write_encoded_flag; ! if (Tcl_GetIntFromObj(interp, objv[2], &write_encoded_flag) != TCL_OK) { Tcl_AppendResult(interp, "Invalid write-encoded flag", NULL ); *************** *** 1103,1106 **** --- 1128,1139 ---- case CStatusIdx: + if (objc > 2) { + int new_status; + if (Tcl_GetIntFromObj(interp, objv[2], &new_status) != TCL_OK) { + Tcl_AppendResult(interp, "Invalid response status code", NULL ); + return TCL_ERROR; + } + Ns_ConnSetResponseStatus(conn, new_status); + } Tcl_SetIntObj(result, Ns_ConnResponseStatus(conn)); break; |