Skip to content

Commit 58c17f8

Browse files
committed
Merge GT-RAIL pull request #19
2 parents 033d5ce + 636c9e3 commit 58c17f8

4 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/http_reply.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,7 @@ bool FilesystemHttpRequestHandler::operator()(const HttpRequest &request, boost:
349349
return false;
350350
}
351351
}
352-
else {
353-
return false;
354-
}
352+
return false;
355353
}
356354

357355

test/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
add_executable(test_web_server EXCLUDE_FROM_ALL test_web_server.cpp)
22
target_link_libraries(test_web_server ${PROJECT_NAME} ${catkin_LIBRARIES})
3-
include_directories(
4-
${catkin_INCLUDE_DIRS}
5-
)
6-
3+
target_include_directories(test_web_server PRIVATE ${catkin_INCLUDE_DIRS})
74

85
if(TARGET tests)
96
add_dependencies(tests

test/simple_http_requests_test.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#! /usr/bin/env python
22

3-
import httplib
3+
import sys
4+
if sys.version_info > (3,):
5+
import http.client as httplib
6+
else:
7+
import httplib
48
import rospy
59
import unittest
610
import time
@@ -48,17 +52,17 @@ def test_default_action(self):
4852
self.conn.request("GET", "/a_static_response")
4953
response = self.conn.getresponse()
5054
self.assertEqual(200, response.status)
51-
self.assertEqual("A RESPONSE", response.read())
55+
self.assertEqual(b"A RESPONSE", response.read())
5256

5357
def test_http_echo1(self):
54-
test_content = "hello HELLO"*1000 # make sure to exceed MTU
58+
test_content = b"hello HELLO"*1000 # make sure to exceed MTU
5559
self.conn.request("GET", "/http_body_echo", test_content)
5660
response = self.conn.getresponse()
5761
self.assertEqual(200, response.status)
5862
self.assertEqual(test_content, response.read())
5963

6064
def test_http_echo2(self):
61-
test_content = "THIS is A test"*1000 # make sure to exceed MTU
65+
test_content = b"THIS is A test"*1000 # make sure to exceed MTU
6266
self.conn.request("POST", "/http_body_echo", test_content)
6367
response = self.conn.getresponse()
6468
self.assertEqual(200, response.status)
@@ -68,25 +72,25 @@ def test_http_path_echo(self):
6872
self.conn.request("GET", "/http_path_echo/this_is_a_test")
6973
response = self.conn.getresponse()
7074
self.assertEqual(200, response.status)
71-
self.assertEqual("/http_path_echo/this_is_a_test", response.read())
75+
self.assertEqual(b"/http_path_echo/this_is_a_test", response.read())
7276

7377
def test_http_query_echo(self):
7478
self.conn.request("GET", "/http_query_echo?hello=1&b=test&c=10")
7579
response = self.conn.getresponse()
7680
self.assertEqual(200, response.status)
77-
self.assertEqual("b=test\nc=10\nhello=1\n", response.read())
81+
self.assertEqual(b"b=test\nc=10\nhello=1\n", response.read())
7882

7983
def test_file(self):
8084
self.conn.request("GET", "/test_file")
8185
response = self.conn.getresponse()
8286
self.assertEqual(200, response.status)
83-
self.assertEqual("<html></html>\n", response.read())
87+
self.assertEqual(b"<html></html>\n", response.read())
8488

8589
def test_file_from_filesystem(self):
8690
self.conn.request("GET", "/test_files/test_dir/test_file.txt")
8791
response = self.conn.getresponse()
8892
self.assertEqual(200, response.status)
89-
self.assertEqual("test\n", response.read())
93+
self.assertEqual(b"test\n", response.read())
9094

9195
def test_directory_listing_forbidden_from_filesystem1(self):
9296
self.conn.request("GET", "/test_files/test_dir/")

test/websocket_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ def test_ok(self):
2020
self.ws.send("hi")
2121
self.assertEqual("hi", self.ws.recv())
2222

23-
self.ws.ping("test ping")
23+
self.ws.ping(b"test ping")
2424
ping_echo = self.ws.recv_frame()
2525
self.assertEqual(9, ping_echo.opcode)
26-
self.assertEqual("test ping", ping_echo.data)
26+
self.assertEqual(b"test ping", ping_echo.data)
2727

28-
self.ws.pong("test pong")
28+
self.ws.pong(b"test pong")
2929
pong_echo = self.ws.recv_frame()
3030
self.assertEqual(10, pong_echo.opcode)
31-
self.assertEqual("test pong", pong_echo.data)
31+
self.assertEqual(b"test pong", pong_echo.data)
3232

3333
if __name__ == '__main__':
3434
time.sleep(1) # ensure server is up

0 commit comments

Comments
 (0)