Url escape variable

Hello

I have this issue trying to use post_action

My config is like this:
location / {
post_action /afterdownload;



location /afterdownload {
proxy_pass
http://78.140.165.80/download_counter.php?FileName=$request&status=$request_completion
;
internal;
}

How to escape the content of $request so it’s a valid URL?

Right now the value there is like (from the log)

78.140.165.80 - - [04/Apr/2013:10:36:53 +0200] "GET
/download_counter.php?FileName=GET
/storage/files/0/1/17/176/myvideo.avi?md=IfHSTECs

I get a 400 (Bad request) for this call and I guess it’s because the
space
after GET inside this variable.

How can I either escape or run a replace on it to remove GET_ from the
beginning of it?