Skip to content

API is responding to preflight check incorrectly. #1049

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

Closed
NodeGuy opened this issue Apr 10, 2015 · 5 comments
Closed

API is responding to preflight check incorrectly. #1049

NodeGuy opened this issue Apr 10, 2015 · 5 comments
Labels
exp/novice Someone with a little familiarity can pick up topic/gateway Topic gateway

Comments

@NodeGuy
Copy link

NodeGuy commented Apr 10, 2015

In CORS mode the client does a preflight check by sending the HTTP OPTIONS verb to the server. IPFS is treating it like a GET and doing actual work. In the case below the preflight check took 10 seconds to complete.

Request:

OPTIONS /api/v0/dht/put?arg=QmYb4yrko8CYoTG2QWEb9KeN1WP6zKfvGTPz46rtcvzfGc&arg=QmNMiA2ge3gVEnxZjke5u4PiBd6uvmQ5gJqLVhG3N8BSKj&stream-channels=true HTTP/1.1
Host: 192.168.99.100:5001
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://192.168.99.100:3000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36
Access-Control-Request-Headers: content-type
Accept: */*
DNT: 1
Referer: http://192.168.99.100:3000/jasmine/SpecRunner.html
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,es-419;q=0.6,es;q=0.4

Response:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Content-Type
content-type: application/json
transfer-encoding: chunked
x-chunked-output: 1
connection: keep-alive
Date: Fri, 10 Apr 2015 18:18:25 GMT

{
  "Extra": "",
  "ID": "QmZjXjTDWjrSDEsKRjQSyaKVvLC7XiWfL4jAau3tz6Vxm4",
  "Responses": null,
  "Type": 5
}{
  "Extra": "",
  "ID": "QmepsDPxWtLDuKvEoafkpJxGij4kMax11uTH7WnKqD25Dq",
  "Responses": null,
  "Type": 5
}{
  "Extra": "",
  "ID": "QmYznNdDCYGTshGr56huHQnYCupP8V2PKFPeqoNUyEPDoh",
  "Responses": null,
  "Type": 5
}{
  "Extra": "",
  "ID": "QmavNkKTvUoE4NaPQZtcmMaxRQqtpbu5jmpTzfH7ScmvHz",
  "Responses": null,
  "Type": 5
}{
  "Extra": "",
  "ID": "QmbDLuhSjnjRG1XLmBCFQRsRjpC4K6UrwwMEaw1Hj4rVE4",
  "Responses": null,
  "Type": 5
}{
  "Extra": "",
  "ID": "QmQbcJy3i44GJ6z8UcVDxCqMupcLEaACAb2aBM68DmiUQE",
  "Responses": null,
  "Type": 5
}{
  "Extra": "",
  "ID": "QmbPXUEDyCdhxBx6geQneWKFLvjedkoyxhyx31HFvxcCvW",
  "Responses": null,
  "Type": 5
}
@whyrusleeping
Copy link
Member

👍 our gateway code needs some work, it also doesnt respond correctly to HEAD requests afaik

@jbenet
Copy link
Member

jbenet commented Apr 10, 2015

@NodeGuy any chance you (or someone else) could help out with fixing this?

@NodeGuy
Copy link
Author

NodeGuy commented Apr 10, 2015

Yes, I'll fix it.

@NodeGuy
Copy link
Author

NodeGuy commented May 4, 2015

I'm digging into the code for the first time and I'm not seeing tests for the API, is that right?

@whyrusleeping
Copy link
Member

@NodeGuy technically yes, there are no tests of the API directly. We do test them indirectly by testing the CLI through sharness in test/sharness

@cryptix cryptix closed this as completed May 14, 2015
@RichardLitt RichardLitt added the exp/novice Someone with a little familiarity can pick up label Feb 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/novice Someone with a little familiarity can pick up topic/gateway Topic gateway
Projects
None yet
Development

No branches or pull requests

5 participants