Move initial state into its own loop with less branches
Move request content encoding into its own method