Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net.http: fix panic on empty addr, cleanup listen_and_serve Server method #21164

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

ttytm
Copy link
Member

@ttytm ttytm commented Apr 1, 2024

Fixes a panic when the server gets an empty address. Does a cleanup to the related scope.

import net.http

mut server := &http.Server{
	addr: ''
	on_running: fn (mut server http.Server) {
		spawn fn [mut server] () {
			println('server started')
			server.stop()
			println('server stopped')
		}()
	}
}
server.listen_and_serve()

Instead it will now behave like before passing 0 to the deprecated port field, or :0 to addr - using a random port.

vlib/net/http/server.v Outdated Show resolved Hide resolved
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit be0986d into vlang:master Apr 2, 2024
42 checks passed
@ttytm ttytm deleted the net.http/server-fix branch April 16, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants