Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

w3link's cache didn't handle accept: application/vnd.ipld.raw correctly #18

Open
Xuanwo opened this issue Sep 8, 2022 · 4 comments
Open
Assignees
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization

Comments

@Xuanwo
Copy link

Xuanwo commented Sep 8, 2022

Hi, I'm the maintainer of OpenDAL: A rust lib for accessing data freely, painlessly, and efficiently. OpenDAL added ipfs support recently. During our test, we found that w3link didn't cache the correct data if the accept header is set.

For example:

QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ is a directory of opendal's test data: https://ipfs.io/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ

  • Without accept: application/vnd.ipld.raw: gateway should return the generated DirIndex.
  • With accept: application/vnd.ipld.raw: gateway should return the raw block.

Background: OpenDAL use accept: application/vnd.ipld.raw to get the raw block of the directory for all child links. In this way, we don't need to parse the returning HTML.

However, w3s.link returns raw block even I didn't set accept header:

Shell Log
:( curl -L https://w3s.link/ipfs/QmPpCt1aYGb9JWJRmXRUnmJtVgeFFTJGzWFYEEX7bo9zGJ | cat
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   488  100   488    0     0    824      0 --:--:-- --:--:-- --:--:--     0
───────┬───────────────────────────────────────────────────────────────────────────────
       │ STDIN
───────┼───────────────────────────────────────────────────────────────────────────────
   1   │ ^R2
   2   │ "^R �T�xj^^ :^Z+c�$���^?!�ș�bs^Fh,͗��c^R
   3   │ normal_dir^X<^R5
   4   │ "^R ߀^Q���^Xe�h��@{�+<)!^P��N�Ie L�c�^B^R^Knormal_file^X��^P^R4
   5   │ "^R )�~�b$^P��zv��'1^Y^QQ�^L^C^B�^Z��γ�b^R
   6   │ ontime.csv^X��^E^R7
   7   │ "^R ��^@^]?�ҹh?�2dD<�IY�~d�d��G�qJ^R^Nontime.csv.bz2^X�5^R6
   8   │ "^R �5�����/0X�l��Sc   -�C^Bڋh�tr��O^R^Montime.csv.gz^X�A^R7
   9   │ "^R �!��Ec��Qj�J7�^R�^Q^M�1]��S^XA^G�o�l�^R^Nontime.csv.zst^X�C^RI
  10   │ "^R �T�xj^^ :^Z+c�$���^?!�ș�bs^Fh,͗��c^R!special_dir  !@#$%^&*()_+-=;'><,?^X<^RL
  11   │ "^R ߀^Q���^Xe�h��@{�+<)!^P��N�Ie L�c�^B^R"special_file  !@#$%^&*()_+-=;'><,?^X��^P
  12   │ ^B^H^A
───────┴───────────────────────────────────────────────────────────────────────────────
@Xuanwo Xuanwo added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Sep 8, 2022
@vasco-santos
Copy link
Contributor

@Xuanwo w3link does not support yet format raw and format car queries. We will look into supporting this soon

@Xuanwo
Copy link
Author

Xuanwo commented Sep 8, 2022

I'm not familiar with js. Maybe we can add &format=raw in query or accept header if input request contains accept: application/vnd.ipld.raw header while redirecting? I'm willing to contribute to this patch.

@Xuanwo
Copy link
Author

Xuanwo commented Sep 8, 2022

The problem I know is Cloudflare's IPFS gateway doesn't support format raw.

@vasco-santos
Copy link
Contributor

Hey @Xuanwo

Thanks for your interest. We probably want to whitelist the gateways that support this and change over time once they support.

If you would like to submit a patch to support this, the repo for it would be the reads pipeline:

@vasco-santos vasco-santos self-assigned this Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

2 participants