B4J Question Different behavior of a filter when using post and download

schimanski

Well-Known Member
Licensed User
Longtime User
I'm not really sure about the function of a filter combined with the staticfilesfolder.

I use the follwing server-settings:

B4X:
srvr.AddHandler("/TEST", "FileServer", False)
srvr.AddFilter("/TEST/*", "PasswortFilter", False)

Every post I send with
B4X:
Dim Status As HttpJob
Status.Initialize("StatusSenden", Me)
Status.PostString("xx.xxx.xxx.xx:51044/TEST?absender=test" & "&passwort=" & PasswortServer & "&type=status", Statusmeldung)

and it goes first through the filter.

When I want do download the file, I use
B4X:
Dim Status As HttpJob
Status.Initialize("StatusLaden", Me)
Status.Download2("xx.xxx.xxx.xx:51044/Kontakte/Status.test.txt", Array As String("passwort", PasswortServer))

The file "Status.test.txt" is lying under the staticfilesfolger /TEST/Kontakte, but the downoad request don't uses the filter. In that way, it is possible to download the file only with

https://xx.xxx.xxx.xx:51044/Kontakte/Status.test.txt

Using

https://xx.xxx.xxx.xx:51044/TEST/Kontakte/Status.Stammi2.eis

checks the filter...

When I set the filter to
B4X:
srvr.AddFilter("/*", "PasswortFilter", False)

the download request goes through the filter, but it is than not possible to register a device, when the user don't has an account.
What can I do to use the filter before downloading a file from my staticfilesfolder?

Thanks for help...
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check the online members example.

B4X:
srvr.AddHandler("/login_example/registerHelper", "RegisterHelper", False)
srvr.AddHandler("/login_example/signinHelper", "SigninHelper", False)
srvr.AddHandler("/login_example/members/membersHandler", "MembersHandler", False)
srvr.AddHandler("/login_example/members/logout", "Logout", False)
'add filter to protect the members only folder
srvr.AddFilter("/login_example/members/*", "MembersFilter", False)
The members folder and the members/* handlers are protected with the filter. You cannot download the index.html file from the members folder unless you are logged in:
https://b4x.com:51041/login_example/members/index.html
 
Upvote 0

schimanski

Well-Known Member
Licensed User
Longtime User
Ok, I think, that i use far to little folders. Must I use the first folder with the name 'www' or doesn't it matter?
 
Upvote 0
Top