A simple `len = REQUEST.size()` should do the trick; then use `REQUEST.c_str()` instead of `buf`