Hi,
I found a commit for aolserver which makes the change to ns_http which I
think I am looking for which treats the data referenced by bodyPtr as a
byte array when appending it to the request in httpPtr->ds.
This stops invalid utf-8 bytes being transformed as when using
Tcl_GetStringFromObj which is what is currently used.

https://github.com/aolserver/aolserver/commit/a6bbca2a509be0e78ffd523860e4904cbb344494#diff-d729ed51b22c10b4e307ad9f4fac22feR522

This allows ns_ssl to POST multipart/form-data requests which contains
binary content, eg. image/png

Would there be any consequences of storing a bytearray inside this dynamic
string as happens in aolserver?

--- a/nsssl.c Wed Jul 01 11:36:49 2015 +0100
+++ b/nsssl.c Wed Jul 29 12:39:37 2015 +0100
@@ -1216,7 +1216,7 @@

     if (bodyPtr != NULL) {
         int len = 0;
- const char *body = Tcl_GetStringFromObj(bodyPtr, &len);
+ const char *body = (char *) Tcl_GetByteArrayFromObj(bodyPtr, &len);
  Ns_DStringPrintf(&httpPtr->ds, "Content-Length: %d\r\n\r\n", len);
         Tcl_DStringAppend(&httpPtr->ds, body, len);
     } else {



On 23 July 2015 at 16:52, David Osborne <da...@qcode.co.uk> wrote:

>
> Question - do ns_http / ns_ssl support raw binary data being passed in via
> the -body argument?
>
> *ns_http queue* ?*-method M*? ?*-headers S*? ?*-body B*? ?*-timeout T*?
> *url*
>
> *-body* body is the value which will be sent as the HTTP request body.
> I'm coming across this receiving a multipart/form-data POST and attempting
> to proxy these requests to an upstream server using ns_ssl.
>
> Regards,
> --
> David Osborne
> Qcode Software Limited
>
>
------------------------------------------------------------------------------
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to