@@ -114,7 +114,6 @@ def validate_outputs(self, outputs, error=None, modifiers=None):
114
114
"attributes" : {
115
115
"component" : "http" ,
116
116
"http.method" : "GET" ,
117
- "http.server_name" : "127.0.0.1" ,
118
117
"http.scheme" : "http" ,
119
118
"host.port" : 80 ,
120
119
"http.host" : "127.0.0.1" ,
@@ -174,7 +173,6 @@ def test_behavior_with_scope_server_as_none(self):
174
173
"""Test that middleware is ok when server is none in scope."""
175
174
def update_expected_server (expected ):
176
175
expected [3 ]['attributes' ].update ({
177
- 'http.server_name' : '0.0.0.0' ,
178
176
'http.host' : '0.0.0.0' ,
179
177
'host.port' : 80 ,
180
178
'http.url' : 'http://0.0.0.0/'
@@ -187,6 +185,21 @@ def update_expected_server(expected):
187
185
outputs = self .get_all_output ()
188
186
self .validate_outputs (outputs , modifiers = [update_expected_server ])
189
187
188
+ def test_host_header (self ):
189
+ """Test that middleware is ok when server is none in scope."""
190
+ hostname = b"server_name_1"
191
+ def update_expected_server (expected ):
192
+ expected [3 ]['attributes' ].update ({
193
+ 'http.server_name' : hostname .decode ('utf8' )
194
+ })
195
+ return expected
196
+ self .scope ["headers" ].append ([b'host' , hostname ])
197
+ app = otel_asgi .OpenTelemetryMiddleware (simple_asgi )
198
+ self .seed_app (app )
199
+ self .send_default_request ()
200
+ outputs = self .get_all_output ()
201
+ self .validate_outputs (outputs , modifiers = [update_expected_server ])
202
+
190
203
191
204
192
205
class TestAsgiAttributes (unittest .TestCase ):
@@ -209,7 +222,6 @@ def test_request_attributes(self):
209
222
"http.url" : "http://127.0.0.1/?foo=bar" ,
210
223
"host.port" : 80 ,
211
224
"http.scheme" : "http" ,
212
- "http.server_name" : "127.0.0.1" ,
213
225
"http.flavor" : "1.0" ,
214
226
"net.peer.ip" : "127.0.0.1" ,
215
227
"net.peer.port" : 32767 ,
0 commit comments