When I open the url /my_path, the function to_jump start to work, a String is generated and then inserted to the HttpBuilder's body. Next the the url jump to /my_path/my_path_next, to which I expected the body generated before will be transported, the function jumped should print out random generated body string, but nothing was printed out.
What am I doing wrong?
that's not how HTTP redirect work. the response with a "Location" header is sent to the client browser, the browser sees the header, and make another request to the new url.
the redirected request is made by the client, so usual techniques to store information on the client side can be used. for example, you can use cookie or encode the information into the redirected url. but that's pretty much what you can do with a redirect.
however, if you are not required to redirect the client to a new url, you can do it with a server middleware.
for example, you can create a regular expression based rewrite (different from redirect) engine, which is essentially an reverse proxy under the hood.