Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Address resolution failures not propagating through HTTP client response processing. #749

Closed
Assignees
deanberris
Labels
@ekigwana

Description

@ekigwana

I built the example cpp-netlib/libs/network/example/http_client1.cpp

#include <boost/network/protocol/http/client.hpp>#include <iostream>int main(int argc, char* argv[]) {  using namespace boost::network;  if (argc != 2) {    std::cout << "Usage: " << argv[0] << " <url>" << std::endl;    return 1;  }  http::client client;  http::client::request request(argv[1]);  request << header("Connection", "close");  http::client::response response = client.get(request);  std::cout << body(response) << std::endl;  return 0;}

I then performed the following simple tests:

  • ./pdu_rcurxhttp://google.com
    status_message: Moved Permanently
    status: 301

  • ./pdu_rcurxhttp://google.comq
    terminate called after throwing an instance of 'boost::exception_detail::clone_implstd::__exception_ptr::exception_ptr'
    Aborted

I seem unable to determine if the request was successful by examining the response.
i.e replacing body(response) with response.status() results in an exception. The only way to not get an exception when the url is invalid to not touch the response. And I also can't seem to catch the error other than via (...) so I can't figure out what happened.

I have looked at all the examples and none of them do any error checking.

(gdb) bt#0  0x00007ffff6080685 in raise () from /lib64/libc.so.6#1  0x00007ffff6081aea in abort () from /lib64/libc.so.6#2  0x00007ffff6967775 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/libstdc++.so.6#3  0x00007ffff6965857 in ?? () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/libstdc++.so.6#4  0x00007ffff6965884 in std::terminate() () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/libstdc++.so.6#5  0x00007ffff6965aae in __cxa_throw () from /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/libstdc++.so.6#6  0x000000000066c8fd in boost::exception_detail::clone_impl<std::__exception_ptr::exception_ptr>::rethrow (this=0x7fffe8000da0)    at /usr/include/boost/exception/exception.hpp:466#7  0x0000000000610d0b in boost::rethrow_exception (p=...) at /usr/include/boost/exception/detail/exception_ptr.hpp:463#8  0x0000000000611561 in boost::detail::shared_state_base::wait_internal (this=0x98eae0, lk=..., rethrow=true)    at /usr/include/boost/thread/future.hpp:337#9  0x00000000006115a4 in boost::detail::shared_state_base::wait (this=0x98eae0, rethrow=true)    at /usr/include/boost/thread/future.hpp:346#10 0x0000000000627072 in boost::detail::shared_state<std::string>::get_sh (this=0x98eae0) at /usr/include/boost/thread/future.hpp:672#11 0x00000000006211c2 in boost::shared_future<std::string>::get (this=0x7fffffffdba0) at /usr/include/boost/thread/future.hpp:1897#12 0x0000000000619022 in boost::network::http::async_message<boost::network::http::tags::http_async_8bit_udp_resolve>::status_message    (this=0x7fffffffdba0) at external/cpp-netlib/boost/network/protocol/http/message/async_message.hpp:57#13 0x0000000000600c58 in main (argc=2, argv=0x7fffffffe1a8) at /home/test/git/hw/pdu_geist/src/main.cpp:16

After spotting future in there, I added a loop that sleeps 1 second 5 times to be sure that everything I instantiated was not destroyed before exception processing was complete. The exception still occurs immediately.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp