Skip to content

Commit ff913ba

Browse files
committed
Don't send routing context in HELLO message for direct connections
1 parent 59e1b42 commit ff913ba

9 files changed

+20
-24
lines changed

neo4j/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,4 @@ class CertificateConfigurationError(ConfigurationError):
308308

309309
class UnsupportedServerProduct(Exception):
310310
""" Raised when an unsupported server product is detected.
311-
"""
311+
"""

neo4j/io/__init__.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def close(self):
556556
class BoltPool(IOPool):
557557

558558
@classmethod
559-
def open(cls, address, *, auth, pool_config, workspace_config, routing_context=None):
559+
def open(cls, address, *, auth, pool_config, workspace_config):
560560
"""Create a new BoltPool
561561
562562
:param address:
@@ -567,22 +567,16 @@ def open(cls, address, *, auth, pool_config, workspace_config, routing_context=N
567567
:return: BoltPool
568568
"""
569569

570-
if routing_context is None:
571-
routing_context = {}
572-
elif "address" in routing_context:
573-
raise ConfigurationError("The key 'address' is reserved for routing context.")
574-
routing_context["address"] = str(address)
575-
576570
def opener(addr, timeout):
577-
return Bolt.open(addr, auth=auth, timeout=timeout, routing_context=routing_context, **pool_config)
571+
return Bolt.open(addr, auth=auth, timeout=timeout, routing_context=None, ** pool_config)
578572

579-
pool = cls(opener, pool_config, workspace_config, routing_context, address)
573+
pool = cls(opener, pool_config, workspace_config, address)
580574
return pool
581575

582-
def __init__(self, opener, pool_config, workspace_config, routing_context, address):
576+
def __init__(self, opener, pool_config, workspace_config, address):
583577
super(BoltPool, self).__init__(opener, pool_config, workspace_config)
584578
self.address = address
585-
self.routing_context = routing_context
579+
self.routing_context = None
586580

587581
def __repr__(self):
588582
return "<{} address={!r}>".format(self.__class__.__name__, self.address)

neo4j/io/_bolt4.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,10 +485,12 @@ def get_base_headers(self):
485485
enables server-side routing to propagate the same behaviour
486486
through its driver.
487487
"""
488-
return {
488+
headers = {
489489
"user_agent": self.user_agent,
490-
"routing": self.routing_context,
491490
}
491+
if self.routing_context is not None:
492+
headers["routing"] = self.routing_context
493+
return headers
492494

493495

494496
class Bolt4x2(Bolt4x1):
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!: BOLT 4.1
22
!: PORT 9001
33

4-
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test", "routing": {"address": "localhost:9001"}}
4+
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test"}
55
S: SUCCESS {"server": "Neo4j/4.1.0", "connection_id": "123e4567-e89b-12d3-a456-426655440000"}
66
C: GOODBYE
7-
S: <EXIT>
7+
S: <EXIT>

tests/stub/scripts/v4x1/return_1_noop_port_9001.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO RESET
44
!: PORT 9001
55

6-
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test", "routing": {"address": "localhost:9001"}}
6+
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test"}
77
S: SUCCESS {"server": "Neo4j/4.1.0", "connection_id": "123e4567-e89b-12d3-a456-426655440000"}
88
C: RUN "RETURN 1 AS x" {} {"mode": "r"}
99
PULL {"n": 2}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
!: BOLT 4.1
22
!: PORT 9001
33

4-
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test", "routing": {"address": "localhost:9001"}}
4+
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test"}
55
S: SUCCESS {"server": "Bogus/4.1.0", "connection_id": "123e4567-e89b-12d3-a456-426655440000"}
66
C: RUN "RETURN 1 AS x" {} {"mode": "r"}
77
PULL {"n": -1}
88
S: SUCCESS {"fields": ["x"]}
99
RECORD [1]
10-
SUCCESS {"bookmark": "neo4j:bookmark-test-1", "type": "r", "t_last": 5, "db": "neo4j"}
10+
SUCCESS {"bookmark": "neo4j:bookmark-test-1", "type": "r", "t_last": 5, "db": "neo4j"}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!: BOLT 4.2
22
!: PORT 9001
33

4-
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test", "routing": {"address": "localhost:9001"}}
4+
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test"}
55
S: SUCCESS {"server": "Neo4j/4.2.0", "connection_id": "123e4567-e89b-12d3-a456-426655440000"}
66
C: GOODBYE
7-
S: <EXIT>
7+
S: <EXIT>

tests/stub/scripts/v4x2/return_1_noop_port_9001.script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO RESET
44
!: PORT 9001
55

6-
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test", "routing": {"address": "localhost:9001"}}
6+
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test"}
77
S: SUCCESS {"server": "Neo4j/4.2.0", "connection_id": "123e4567-e89b-12d3-a456-426655440000"}
88
C: RUN "RETURN 1 AS x" {} {"mode": "r"}
99
PULL {"n": 2}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
!: BOLT 4.2
22
!: PORT 9001
33

4-
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test", "routing": {"address": "localhost:9001"}}
4+
C: HELLO {"user_agent": "test", "scheme": "basic", "principal": "test", "credentials": "test"}
55
S: SUCCESS {"server": "Bogus/4.2.0", "connection_id": "123e4567-e89b-12d3-a456-426655440000"}
66
C: RUN "RETURN 1 AS x" {} {"mode": "r"}
77
PULL {"n": -1}
88
S: SUCCESS {"fields": ["x"]}
99
RECORD [1]
10-
SUCCESS {"bookmark": "neo4j:bookmark-test-1", "type": "r", "t_last": 5, "db": "neo4j"}
10+
SUCCESS {"bookmark": "neo4j:bookmark-test-1", "type": "r", "t_last": 5, "db": "neo4j"}

0 commit comments

Comments
 (0)