Skip to content

Allow binary data in response #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jonathanstowe opened this issue Jul 15, 2020 · 2 comments
Open

Allow binary data in response #7

jonathanstowe opened this issue Jul 15, 2020 · 2 comments
Assignees

Comments

@jonathanstowe
Copy link
Owner

Hi Jonathan,

I am having trouble serving binary files with FastCGI::NativeCall::PSGI

I have traced this through to a call to XS_Print which takes a C-style string, so there seems to be no way to send binary data via FastCGI::NativeCall.

I have successfully hacked around it by adding a XS_Write that takes a length argument (and a Write method that takes a Blob instead of Str.) I am just wondering if I missed something and I'm using the API wrong, or if this is actually a missing feature.

Regards
Aleks

@jonathanstowe
Copy link
Owner Author

It's make the Print method a multi and alter the XS_print

@aleksb
Copy link

aleksb commented Jul 15, 2020

This is what I added to XS.c

int XS_Write(void *buf, int len, FCGX_Request *request)
{
        int ret;
        if (!request->out)
                return -1;
        ret = FCGX_PutStr(buf, len, request->out);
        return ret;
}

and NativeCall.rakumod:

method Write(Blob $content) {
    XS_Write(nativecast(Pointer, $content), $content.bytes, $!fcgx_req);
}

Maybe a multimethod would be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants