Several places in the httpd expect that the user first requests a length and then provides a char * buffer with matching space.
I would like to provide a bytearray or similar as the buffer. But MP expects a string when the parameter was a char *.
My current solution looks like this:
def get_header_value(req, name):
blen = req.get_hdr_value_len(name);
if not blen: return None
buffer = " "*blen # allocate a string as buffer incl. space for \0
req.get_hdr_value_str(name, buffer, blen+1);
return buffer;
I am not sure if this is a safe solution. Are python string buffers always 0 terminated char arrays internally so that " "*32 is actually 33 bytes? Can I just overwrite them?