- 
                Notifications
    
You must be signed in to change notification settings  - Fork 381
 
Open
Description
I having trouble with the rest api receving in array format when the webclient(swagger-ui) is msedge and opera. Does not happen to Chrome and firefox.
I use the openapi generator to generate the code below
std::string ServerSet_eventRemote_nameResource::extractBodyContent(const std::shared_ptr<restbed::Session>& session) {
  const auto request = session->get_request();
  int content_length = request->get_header("Content-Length", 0);
  std::string bodyContent;
  session->fetch(content_length,
                 [&bodyContent](const std::shared_ptr<restbed::Session> session,
                                const restbed::Bytes &body) {
                    std::cout << body.data() << std::endl;
                    bodyContent = restbed::String::format(
                       "%.*s\n", (int)body.size(), body.data());
                 });
  return bodyContent;
}
and the std::cout << body.data() << std::endl; return me the header instead of the actual json body. With Chrome a proper json body was cout.
Host: ubuntu-virtual-machine.local:8081
Connection: keep-alive
Content-Length: 289
sec-ch-ua-platform: "Windows"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Thread 1 "server1" received signal SIGSEGV, Segmentation fault.
0x00007ffff6f4c517 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) () from /lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0  0x00007ffff6f4c517 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&&) ()
   from /lib/x86_64-linux-gnu/libstdc++.so.6
#1  0x00005555556a7e7e in operator() (__closure=0x55555bab9240, session=warning: RTTI symbol not found for class 'std::_Sp_counted_ptr_inplace<restbed::Session, std::allocator<restbed::Session>, (__gnu_cxx::_Lock_policy)2>'
warning: RTTI symbol not found for class 'std::_Sp_counted_ptr_inplace<restbed::Session, std::allocator<restbed::Session>, (__gnu_cxx::_Lock_policy)2>'
std::shared_ptr<restbed::Session> (use count 6, weak count 1) = {...}, body=std::vector of length 289, capacity 289 = {...})
    at src/openapi/api/ServerModeApi.cpp:300
#2  0x00005555556a8e88 in std::__invoke_impl<void, org::openapitools::server::api::ServerModeApiResources::ServerSet_eventRemote_nameResource::extractBodyContent(const std::shared_ptr<restbed::Session>&)::<lambda(std::shared_ptr<restbed::Session>, const Bytes&)>&, std::shared_ptr<restbed::Session>, const std::vector<unsigned char, std::allocator<unsigned char> >&>(std::__invoke_other, struct {...} &) (
    __f=...) at /usr/include/c++/11/bits/invoke.h:61
#3  0x00005555556a8ce2 in std::__invoke_r<void, org::openapitools::server::api::ServerModeApiResources::ServerSet_eventRemote_nameResource::extractBodyContent(const std::shared_ptr<restbed::Session>&)::<lambda(std::shared_ptr<restbed::Session>, const Bytes&)>&, std::shared_ptr<restbed::Session>, const std::vector<unsigned char, std::allocator<unsigned char> >&>(struct {...} &) (__fn=...)
    at /usr/include/c++/11/bits/invoke.h:111
#4  0x00005555556a89ae in std::_Function_handler<void(std::shared_ptr<restbed::Session>, const std::vector<unsigned char, std::allocator<unsigned char> >&), org::openapitools::server::api::ServerModeApiResources::ServerSet_eventRemote_nameResource::extractBodyContent(const std::shared_ptr<restbed::Session>&)::<lambda(std::shared_ptr<restbed::Session>, const Bytes&)> >::_M_invoke(const std::_Any_data &, std::shared_ptr<restbed::Session> &&, const std::vector<unsigned char, std::allocator<unsigned char> > &) (__functor=..., __args#0=..., __args#1=std::vector of length 289, capacity 289 = {...})
    at /usr/include/c++/11/bits/std_function.h:290
#5  0x00007ffff78fdbb1 in std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)>::operator()(std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&) const () from /home/ubuntu/server1/bin/../thirdparty/library/librestbed.so.4
#6  0x00007ffff78fb4c9 in restbed::detail::SessionImpl::fetch_body(unsigned long, std::shared_ptr<restbed::Session>, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&) const () from /home/ubuntu/server1/bin/../thirdparty/library/librestbed.so.4
#7  0x00007ffff799eeff in restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)::{lambda(std::error_code const&, unsigned long)#1}::operator()(std::error_code const&, unsigned long) const () from /home/ubuntu/server1/bin/../thirdparty/library/librestbed.so.4
#8  0x00007ffff79a3595 in void std::__invoke_impl<void, restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)::{lambda(std::error_code const&, unsigned long)#1}&, std::error_code const&, unsigned long>(std::__invoke_other, restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)::{lambda(std::error_code const&, unsigned long)#1}&, std::error_code const&, unsigned long&&) ()
   from /home/ubuntu/server1/bin/../thirdparty/library/librestbed.so.4
#9  0x00007ffff79a2918 in std::enable_if<std::__and_<std::is_void<void>, std::__is_invocable<restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)::{lambda(std::error_code const&, unsigned long)#1}&, std::error_code const&, unsigned long> >::value, void>::type std::__invoke_r<void, restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)::{lambda(std::error_code const&, unsigned long)#1}&, std::error_code const&, unsigned long>(restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)::{lambda(std::error_code const&, unsigned long)#1}&, std::error_code const&, unsigned long&&) () from /home/ubuntu/server1/bin/../thirdparty/library/librestbed.so.4
#10 0x00007ffff79a182c in std::_Function_handler<void (std::error_code const&, unsigned long), restbed::Session::fetch(unsigned long, std::function<void (std::shared_ptr<restbed::Session>, std::vector<unsigned char, std::allocator<unsigned char> > const&)> const&)::{lambda(std::error_code const&, unsigned long)#1}>::_M_invoke(std::_Any_data const&, std::error_code const&, unsigned long&&) ()
   from /home/ubuntu/server1/bin/../thirdparty/library/librestbed.so.4
#11 0x00007ffff7954277 in std::function<void (std::error_code const&, unsigned long)>::operator()(std::error_code const&, unsigned long) const ()
Any idea that is the case?
Metadata
Metadata
Assignees
Labels
No labels