And one thing more..
I've read source of proxy_pass / memcached module to check how they use upstream. Unfortunately upstream servers are defined in nginx configure file. It's useless for us. We need to parse incoming buffers in filter, find server uri and download some content.
Is there another way to configure upstream? During work of body_filter?
In upstream.h there is only one function which adds upstream server:
ngx_http_upstream_srv_conf_t *ngx_http_upstream_add(ngx_conf_t *cf, ngx_url_t *u, ngx_uint_t flags);
It requires ngx_conf_t *cf, so it must be used during creating configuration...