does eCAP support replacing file downloading

Asked by Bob

does anyone know how to write a eCAP adapter to replace file downloading through http?

for instance, if someone is downloading a file named a.txt from web, with the help of the adapter i can give him b.txt.

can eCAP make it?

Question information

English Edit question
eCAP Edit question
No assignee Edit question
Solved by:
Alex Rousskov
Last query:
Last reply:
Revision history for this message
Alex Rousskov (rousskov) said :

If you simply want to redirect the user from URL A to URL B, you may rewrite the Request URI in REQMOD. This will result in the host application downloading b.txt instead of a.txt.

I believe the following FAQ answers your question if you want to generate the [b.txt] response inside the adapter and prevent the host application from downloading a.txt and b.txt:

FAQ #2516: “Can an adapter respond to requests instead of adapting them?”.

Revision history for this message
Bob (362061693-k) said :

thanks Alex.

since I have just begun to know eCAP for a very short time, maybe it is difficult for me to describe my requirement clearyly :(

what i want to do is that when the user download a.txt, i can replace a.txt with b.txt in background, and the user still feels he is downloading a.txt, namely there is no any obvious sign to let the user know a.txt has been replaced by b.txt.

Revision history for this message
Best Alex Rousskov (rousskov) said :

Absolute invisibility is impossible in general, but both answers I gave you would satisfy your "no obvious signs" requirement, for some definition of "obvious". The difference between the two options is in what software "downloads" b.txt:

1. URI rewrite: The host application (e.g., Squid) downloads b.txt.
2. Request satisfaction: Adapter downloads downloads b.txt (or loads it from a local file, etc.).

If b.txt needs to be computed dynamically based on a.txt, then you need a third option:

3. RESPMOD: The host application downloads a.txt and the adapter rewrites the a.txt response to become b.txt.

It may help if you start thinking in terms of HTTP messages (requests/responses with headers and body) rather than files (directionless name and body). The complexity of what is or may be going on and all the different adaptation options is difficult to describe and understand in "a.txt" and "b.txt" terms.

Revision history for this message
Bob (362061693-k) said :

thank you very much, Alex :)

yeah, your this answer is quite helpful for me. indeed, i know absolute invisiblity is impossible, what i want is just "no obvious signs ", so i will try the options you gave me. if meeting any problem when i wirte the adapter, i still have to disturb you again :)

Revision history for this message
Bob (362061693-k) said :

Thanks Alex Rousskov, that solved my question.

Revision history for this message
Bob (362061693-k) said :

ok, I will carefully do some research on FAQ #2516. thanks a lot