File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ pub async fn Client::connect(
7575 conn .write ("\r\n " )
7676
7777 // Read and validate handshake response
78- let reader = @io . BufferedReader :: new ( conn )
79- guard reader .read_line ( ) is Some (response_line ) else {
78+ let reader = conn
79+ guard reader .read_until ( " \r\n " ) is Some (response_line ) else {
8080 conn .close ()
8181 raise InvalidHandshake ("Server closed connection during handshake" )
8282 }
@@ -88,11 +88,10 @@ pub async fn Client::connect(
8888 )
8989 }
9090 let headers : Map [String , String ] = {}
91- while reader .read_line ( ) is Some (line ) {
91+ while reader .read_until ( " \r\n " ) is Some (line ) {
9292 if line .is_blank () {
9393 break
9494 }
95- let line = line [:- 1 ] // Remove trailing \r
9695
9796 // Parse header line
9897 if line .contains (":" ) {
Original file line number Diff line number Diff line change @@ -26,11 +26,11 @@ struct ServerConnection {
2626/// This performs the full HTTP upgrade handshake
2727async fn ServerConnection ::handshake (conn : @socket .Tcp ) -> ServerConnection {
2828 // Read HTTP request
29- let reader = @io . BufferedReader :: new ( conn )
29+ let reader = conn
3030
3131 // Read request line
32- let request_line = match reader .read_line ( ) {
33- Some (line ) => line [: - 1 ] // Remove trailing \r
32+ let request_line = match reader .read_until ( " \r\n " ) {
33+ Some (line ) => line // Remove trailing \r
3434 None => raise InvalidHandshake ("Empty request" )
3535 }
3636
@@ -41,12 +41,11 @@ async fn ServerConnection::handshake(conn : @socket.Tcp) -> ServerConnection {
4141
4242 // Read and parse headers
4343 let headers : Map [String , String ] = {}
44- while reader .read_line ( ) is Some (line ) {
44+ while reader .read_until ( " \r\n " ) is Some (line ) {
4545 // Empty line marks end of headers
4646 if line .is_blank () {
4747 break
4848 }
49- let line = line [:- 1 ] // Remove trailing \r
5049
5150 // Parse header line
5251 if line .contains (":" ) {
You can’t perform that action at this time.
0 commit comments