does eCAP support replacing file downloading

Asked by Bob on 2015-11-09

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

Language:
English Edit question
Status:
Solved
For:
eCAP Edit question
Assignee:
No assignee Edit question
Solved by:
Alex Rousskov
Solved:
2015-11-10
Last query:
2015-11-10
Last reply:
2015-11-09
Alex Rousskov (rousskov) said : #1

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?”.

Bob (362061693-k) said : #2

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.

Best Alex Rousskov (rousskov) said : #3

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.

Bob (362061693-k) said : #4

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 :)

Bob (362061693-k) said : #5

Thanks Alex Rousskov, that solved my question.

Bob (362061693-k) said : #6

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