39 from __future__
import print_function
41 PKG =
'rospy_tutorials' 42 NAME =
'test_client_connection_header' 54 super(TestClientConnectionHeader, self).
__init__(*args)
59 x = random.randint(0, 1000)
60 y = random.randint(0, 1000)
62 rospy.wait_for_service(
'add_two_ints')
67 metadata = {
'cookies' :
'peanut butter' }
68 add_two_ints = rospy.ServiceProxy(
'add_two_ints', AddTwoInts, headers=metadata)
70 print(
"Requesting %s+%s with cookies=%s" % (x, y, metadata[
'cookies']))
74 print(
"Server's connection headers were", resp._connection_header)
75 self.assert_(
'callerid' in resp._connection_header)
78 except rospy.ServiceException
as e:
79 print(
"Service call failed: %s" % e)
82 if __name__ ==
'__main__':
83 if '--node' in sys.argv:
86 rospy.init_node(
'sch_test_client', anonymous=
True)
88 service_name =
'add_two_ints_header_test' 89 rospy.wait_for_service(service_name)
90 metadata = {
'cookies' :
'peanut butter' }
91 add_two_ints = rospy.ServiceProxy(service_name, AddTwoInts, headers=metadata)
93 while not rospy.is_shutdown():
97 except rospy.ServiceException
as e:
100 rostest.rosrun(PKG, NAME, TestClientConnectionHeader, sys.argv)