1
- from memory import UnsafePointer
1
+ from memory import UnsafePointer, Span
2
2
from collections import Optional
3
3
from sys.ffi import external_call, OpaquePointer
4
4
from lightbug_http.strings import to_string
5
+ from lightbug_http.io.bytes import ByteView
6
+ from lightbug_http._logger import logger
7
+ from lightbug_http.socket import Socket
5
8
from lightbug_http._libc import (
6
9
c_int,
7
10
c_char,
@@ -20,8 +23,6 @@ from lightbug_http._libc import (
20
23
INET_ADDRSTRLEN ,
21
24
INET6_ADDRSTRLEN ,
22
25
)
23
- from lightbug_http._logger import logger
24
- from lightbug_http.socket import Socket
25
26
26
27
alias MAX_PORT = 65535
27
28
alias MIN_PORT = 0
@@ -394,24 +395,24 @@ fn resolve_localhost(host: String, network: NetworkType) -> String:
394
395
395
396
return host
396
397
397
- fn parse_ipv6_bracketed_address (address : String ) raises -> (String , UInt16):
398
+ fn parse_ipv6_bracketed_address (address : ByteView[ImmutableAnyOrigin] ) raises -> (ByteView[ImmutableAnyOrigin] , UInt16):
398
399
""" Parse an IPv6 address enclosed in brackets.
399
400
400
401
Returns:
401
402
Tuple of (host, colon_index_offset)
402
403
"""
403
- if address[0 ] != " [" :
404
+ if address[0 ] != Byte( ord ( " [" )) :
404
405
return address, UInt16(0 )
405
406
406
- var end_bracket_index = address.find(" ]" )
407
+ var end_bracket_index = address.find(Byte( ord ( " ]" )) )
407
408
if end_bracket_index == - 1 :
408
409
raise Error(" missing ']' in address" )
409
410
410
411
if end_bracket_index + 1 == len (address):
411
412
raise MissingPortError
412
413
413
414
var colon_index = end_bracket_index + 1
414
- if address[colon_index] != " :" :
415
+ if address[colon_index] != Byte( ord ( " :" )) :
415
416
raise MissingPortError
416
417
417
418
return (
0 commit comments