rem: strcpy(interp->result, itPtr->nsconn.hdrs);
add: strcpy(itPtr->nsconn.hdrs, interp->result);
context: NsTclConnCmd(ClientData arg, Tcl_Interp *interp, int argc, char **argv){    NsInterp   *itPtr = arg;    Ns_Conn    *conn = itPtr->conn;    Conn       *connPtr = (Conn *) conn;    Ns_Request *request;    Ns_Set     *form;    int		urlv, idx;    if (argc < 2) {badargs:        Tcl_AppendResult(interp, "wrong # of args: should be \"",                         argv[0], " cmd ", NULL);        return TCL_ERROR;    }    urlv = STREQ(argv[1], "urlv");    if (!urlv) {	if (argc > 3) {	    goto badargs;	}	if (argc == 3 && !NsIsIdConn(argv[2])) {badconn:	    Tcl_AppendResult(interp, "invalid connid: \"", argv[2], "\"", NULL);	    return TCL_ERROR;	}    } else {	/*	 * Special treatment for urlv command.	 */	switch (argc) {	case 2:	    idx = -1;	    break;	case 3:	    /* NB: Ambiguous, check conn id then assume arg is index. */	    if (NsIsIdConn(argv[2])) {		idx = -1;	    } else if (Tcl_GetInt(interp, argv[2], &idx) != TCL_OK) {		return TCL_ERROR;	    }	    break;	case 4:	    if (!NsIsIdConn(argv[2])) {		goto badconn;	    }	    if (Tcl_GetInt(interp, argv[3], &idx) != TCL_OK) {		return TCL_ERROR;	    }	    break;	default:	    goto badargs;	}    }    if (STREQ(argv[1], "isconnected")) {	Tcl_SetResult(interp, (connPtr == NULL) ? "0" : "1", TCL_STATIC);	return TCL_OK;    }    /*     * All remaining commands require a conn.     */    if (connPtr == NULL) {        Tcl_AppendResult(interp, "no current connection", NULL);        return TCL_ERROR;    }    request = connPtr->request;    if (urlv) {	if (idx < 0) {	    for (idx = 0; idx < request->urlc; idx++) {	        Tcl_AppendElement(interp, request->urlv[idx]);	    }	} else if (idx >= 0 && idx < request->urlc) {	    Tcl_SetResult(interp, request->urlv[idx], TCL_VOLATILE);	}    } else if (STREQ(argv[1], "authuser")) {        Tcl_SetResult(interp, connPtr->authUser, TCL_STATIC);    } else if (STREQ(argv[1], "authpassword")) {        Tcl_SetResult(interp, connPtr->authPasswd, TCL_STATIC);    } else if (STREQ(argv[1], "contentlength")) {        sprintf(interp->result, "%u", (unsigned) conn->contentLength);    } else if (STREQ(argv[1], "peeraddr")) {        Tcl_SetResult(interp, Ns_ConnPeer(conn), TCL_STATIC);    } else if (STREQ(argv[1], "peerport")) {	sprintf(interp->result, "%d", Ns_ConnPeerPort(conn));    } else if (STREQ(argv[1], "headers")) {	if (itPtr->nsconn.flags & CONN_TCLHDRS) {            Tcl_SetResult(interp, itPtr->nsconn.hdrs, TCL_STATIC);	} else {            Ns_TclEnterSet(interp, connPtr->headers, NS_TCL_SET_STATIC);	    strcpy(interp->result, itPtr->nsconn.hdrs);	    itPtr->nsconn.flags |= CONN_TCLHDRS;	}    } else if (STREQ(argv[1], "outputheaders")) {	if (itPtr->nsconn.flags & CONN_TCLHDRS) {            Tcl_SetResult(interp, itPtr->nsconn.outhdrs, TCL_STATIC);	} else {            Ns_TclEnterSet(interp, connPtr->outputheaders, NS_TCL_SET_STATIC);	    strcpy(interp->result, itPtr->nsconn.outhdrs);	    itPtr->nsconn.flags |= CONN_TCLOUTHDRS;	}    } else if (STREQ(argv[1], "form")) {	if (itPtr->nsconn.flags & CONN_TCLFORM) {            Tcl_SetResult(interp, itPtr->nsconn.form, TCL_STATIC);	} else {            form = Ns_ConnGetQuery(conn);            if (form == NULL) {        	itPtr->nsconn.form[0] = '\0';	    } else {		form = Ns_SetCopy(form);                Ns_TclEnterSet(interp, form, NS_TCL_SET_DYNAMIC);        	strcpy(itPtr->nsconn.form, interp->result);	    }	    itPtr->nsconn.flags |= CONN_TCLFORM;	}    } else if (STREQ(argv[1], "request")) {        Tcl_SetResult(interp, request->line, TCL_STATIC);    } else if (STREQ(argv[1], "method")) {        Tcl_SetResult(interp, request->method, TCL_STATIC);    } else if (STREQ(argv[1], "protocol")) {        Tcl_SetResult(interp, request->protocol, TCL_STATIC);    } else if (STREQ(argv[1], "host")) {        Tcl_SetResult(interp, request->host, TCL_STATIC);    } else if (STREQ(argv[1], "port")) {        sprintf(interp->result, "%d", request->port);    } else if (STREQ(argv[1], "url")) {        Tcl_SetResult(interp, request->url, TCL_STATIC);    } else if (STREQ(argv[1], "query")) {        Tcl_SetResult(interp, request->query, TCL_STATIC);    } else if (STREQ(argv[1], "urlc")) {        sprintf(interp->result, "%d", request->urlc);    } else if (STREQ(argv[1], "version")) {        sprintf(interp->result, "%1.1f", request->version);    } else if (STREQ(argv[1], "location")) {        Tcl_SetResult(interp, Ns_ConnLocation(conn), TCL_STATIC);    } else if (STREQ(argv[1], "driver")) {	Tcl_AppendResult(interp, Ns_ConnDriverName(conn), NULL);    } else if (STREQ(argv[1], "server")) {        Tcl_SetResult(interp, Ns_ConnServer(conn), TCL_STATIC);    } else if (STREQ(argv[1], "status")) {        sprintf(interp->result, "%d", Ns_ConnResponseStatus(conn));    } else if (STREQ(argv[1], "sock")) {	sprintf(interp->result, "%d", Ns_ConnSock(conn));    } else if (STREQ(argv[1], "id")) {	sprintf(interp->result, "%d", Ns_ConnId(conn));    } else if (STREQ(argv[1], "flags")) {	sprintf(interp->result, "%d", connPtr->flags);    } else if (STREQ(argv[1], "start")) {	sprintf(interp->result, "%d", (int) connPtr->startTime);    } else if (STREQ(argv[1], "close")) {        if (Ns_ConnClose(conn) != NS_OK) {            Tcl_SetResult(interp, "could not close connection", TCL_STATIC);            return TCL_ERROR;        }    } else {        Tcl_AppendResult(interp, "unknown command \"", argv[1],			 "\":  should be "                         "authpassword, "                         "authuser, "                         "close, "                         "content, "                         "contentlength, "                         "driver, "                         "flags, "                         "form, "                         "headers, "                         "host, "                         "isconnected, "                         "location, "                         "method, "                         "outputheaders, "                         "peeraddr, "			 "peerport, "                         "port, "                         "protocol, "                         "url, "                         "query, "                         "server, "			 "sock, "                         "start, "                         "status, "                         "urlc, "                         "urlv, "                         "or version", NULL);        return TCL_ERROR;    }    return TCL_OK;}