fangfufu / httpdirfs

A filesystem which allows you to mount HTTP directory listings or a single file, with a permanent cache. Now with Airsonic / Subsonic support!
Other
763 stars 59 forks source link

Setting --user-agent is not working #159

Closed redindian closed 2 months ago

redindian commented 2 months ago

The option --user-agent does not seem to work. I've added a debug line and the argument is not parsed. I've also debugged the headers sent and the user agent is still the default.

fangfufu commented 2 months ago

I will investigate this when I have time.

fangfufu commented 2 months ago

By running

$ ./httpdirfs --user-agent "bldfgh" --cache http://127.0.0.1/test/ test
$ cd test
$ tree

In my apache log, I find the followings:

127.0.0.1 - - [23/Jul/2024:23:15:27 +0100] "GET /test/abc%20cde/ HTTP/1.1" 200 1527 "-" "bldfgh"
127.0.0.1 - - [23/Jul/2024:23:15:27 +0100] "HEAD /test/abc%20cde/test.txt HTTP/1.1" 200 226 "-" "bldfgh"
127.0.0.1 - - [23/Jul/2024:23:15:27 +0100] "HEAD /test/abc%20cde/test%20fgdf.txt HTTP/1.1" 200 226 "-" "bldfgh"
127.0.0.1 - - [23/Jul/2024:23:15:27 +0100] "GET /test/abc%20cde/test.test/ HTTP/1.1" 200 1150 "-" "bldfgh"
127.0.0.1 - - [23/Jul/2024:23:15:27 +0100] "HEAD /test/abc%20cde/test.test/test.txt HTTP/1.1" 200 226 "-" "bldfgh"
127.0.0.1 - - [23/Jul/2024:23:15:28 +0100] "GET /test/test%20123.com/ HTTP/1.1" 200 1130 "-" "bldfgh"
127.0.0.1 - - [23/Jul/2024:23:15:28 +0100] "HEAD /test/test%20123.com/test.txt HTTP/1.1" 200 226 "-" "bldfgh"
10.1.6.1 - fangfufu [23/Jul/2024:23:15:24 +0100] "PROPFIND /nextcloud/remote.php/dav/files/fangfufu/ HTTP/1.1" 207 1108 "-"

Cannot reproduce as of e3b2904b5f0df66252d63a57300239c777d25189

redindian commented 2 months ago

Just had time to check. The problem is with the --single-file-mode option. Logs below for your test and the same with --single-file-mode enabled:

127.0.0.1 - - [02/Aug/2024:19:16:58 +0000] "GET /test/ HTTP/1.1" 404 432 "-" "bldfgh"
127.0.0.1 - - [02/Aug/2024:19:18:56 +0000] "HEAD /test/ HTTP/1.1" 404 140 "-" "HTTPDirFS-1.2.5"

Try this to test:

./httpdirfs --single-file-mode --user-agent "bldfgh" --cache http://127.0.0.1/test/ test
fangfufu commented 2 months ago

Yup, I can confirm it doesn't work on single file mode.

fangfufu@smithsonian:~/projects/httpdirfs$ ./httpdirfs -f --single-file-mode --user-agent "bldfgh" --cache http://127.0.0.1/test/1.txt test
LinkTable_print: --------------------------------------------
LinkTable_print:  LinkTable 0x55611c64bea0 for http://127.0.0.1/test/1.txt
LinkTable_print: --------------------------------------------
LinkTable_print: 0 H 0  http://127.0.0.1/test/1.txt
LinkTable_print: 1 F 8 1.txt http://127.0.0.1/test/1.txt
LinkTable_print: --------------------------------------------
LinkTable_print:  Invalid link count: 0
LinkTable_print: --------------------------------------------
fs_open: /1.txt
Link_download: requested size too larger than remaining size, req_size: 8388608, recv: 140451928020976, content-length: 8
fs_release: /1.txt
fangfufu commented 2 months ago
./httpdirfs -f --single-file-mode --user-agent "bldfgh" http://127.0.0.1/test/1.txt test

and

./httpdirfs -f --user-agent "bldfgh" --single-file-mode http://127.0.0.1/test/1.txt test

have different behaviours. This is bad.

fangfufu commented 2 months ago

Thanks, I believe this is now fixed.

redindian commented 1 month ago

Just pulled and tested it, works now, thanks a lot for the quick fix!