From: Vlad S. <ser...@us...> - 2007-03-27 03:18:48
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv30455/nsd Modified Files: tclhttp.c Log Message: * nsd/tclhttp.c: Updated to properly handle binary results in ns_http wait command Index: tclhttp.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclhttp.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** tclhttp.c 17 Mar 2007 20:15:15 -0000 1.7 --- tclhttp.c 27 Mar 2007 03:18:47 -0000 1.8 *************** *** 63,67 **** static int HttpConnect(Tcl_Interp *interp, char *method, char *url, Ns_Set *hdrs, Tcl_Obj *bodyPtr, Http **httpPtrPtr); ! static char *HttpResult(char *response, int *statusPtr, Ns_Set *hdrs); static void HttpClose(Http *httpPtr); static void HttpCancel(Http *httpPtr); --- 63,67 ---- static int HttpConnect(Tcl_Interp *interp, char *method, char *url, Ns_Set *hdrs, Tcl_Obj *bodyPtr, Http **httpPtrPtr); ! static Tcl_Obj *HttpResult(Tcl_DString *ds, int *statusPtr, Ns_Set *hdrs); static void HttpClose(Http *httpPtr); static void HttpCancel(Http *httpPtr); *************** *** 274,278 **** Tcl_Obj *statusPtr = NULL; Ns_Time *timeoutPtr = NULL; ! char *content, *id = NULL; Ns_Set *hdrPtr = NULL; Http *httpPtr; --- 274,278 ---- Tcl_Obj *statusPtr = NULL; Ns_Time *timeoutPtr = NULL; ! char *id = NULL; Ns_Set *hdrPtr = NULL; Http *httpPtr; *************** *** 318,322 **** goto err; } ! content = HttpResult(httpPtr->ds.string, &status, hdrPtr); if (statusPtr != NULL && !SetWaitVar(interp, statusPtr, Tcl_NewIntObj(status))) { --- 318,322 ---- goto err; } ! valPtr = HttpResult(&httpPtr->ds, &status, hdrPtr); if (statusPtr != NULL && !SetWaitVar(interp, statusPtr, Tcl_NewIntObj(status))) { *************** *** 324,330 **** } if (resultPtr == NULL) { ! Tcl_SetResult(interp, content, TCL_VOLATILE); } else { ! if (!SetWaitVar(interp, resultPtr, Tcl_NewStringObj(content, -1))) { goto err; } --- 324,330 ---- } if (resultPtr == NULL) { ! Tcl_SetObjResult(interp, valPtr); } else { ! if (!SetWaitVar(interp, resultPtr, valPtr)) { goto err; } *************** *** 542,552 **** */ ! static char * ! HttpResult(char *response, int *statusPtr, Ns_Set *hdrs) { int firsthdr, major, minor, len; ! char *eoh, *body, *p, save; ! body = response; eoh = strstr(response, "\r\n\r\n"); if (eoh != NULL) { --- 542,553 ---- */ ! static Tcl_Obj * ! HttpResult(Tcl_DString *ds, int *statusPtr, Ns_Set *hdrs) { + char *eoh, *body, *p, save, *response; int firsthdr, major, minor, len; ! Tcl_Obj *result; ! body = response = ds->string; eoh = strstr(response, "\r\n\r\n"); if (eoh != NULL) { *************** *** 560,563 **** --- 561,567 ---- } } + + result = Tcl_NewByteArrayObj((unsigned char*)body, ds->length-(body-response)); + if (eoh == NULL) { *statusPtr = 0; *************** *** 590,598 **** } } ! return body; } - - static void HttpClose(Http *httpPtr) --- 594,600 ---- } } ! return result; } static void HttpClose(Http *httpPtr) |