I have embedded system with web socket communication. I can connect via SSL to firebase server and then do HTTP stream request so every time is something changed in DB I get notified. Everything works great but there is one thing mentioned in Firebase REST API docs which worries me. And that is point two:
2. Respect HTTP Redirects, in particular HTTP status code 307
I am requesting:
https://fakeproject-b66a6-default-rtdb.europe-west1.firebasedatabase.app/mySecretKey.json"
- Do you know what will be the form of the
Location
key in the header in case of redirect?
- Will it be just path on the same server?
- Or will it be URL to the deferent one with
http://
orwww.
prefix?
- Will it contain my
mySecretKey.json
at the end? - Is there a possibility to try it out somewhere so I get 307 from firebase?
I need to know this because I have to properly parse it and make second request to redirect location.
CodePudding user response:
The servers for the Firebase Realtime Database REST API used to use 307 codes to redirect you to the correct server. Nowadays, they don't use a 307 as frequently anymore, but it may still occur during an update or when traffic is being moved around.
For an example of what you may get, you can try:
curl -v -H "Accept: text/event-stream" "https://s-euw1b-nss-500.europe-west1.firebasedatabase.app/test.json?ns=patryk-newest-rtdb-eu"
By passing an Accept: text/event-stream
header we prevent the proxying that would otherwise happen, so we can see the redirect flow.
The response I'm getting:
< HTTP/1.1 307 Temporary Redirect
< Server: nginx
< Date: Fri, 25 Mar 2022 00:18:05 GMT
< Content-Type: text/plain
< Content-Length: 0
< Connection: keep-alive
< Location: https://s-euw1b-nss-200.europe-west1.firebasedatabase.app/test.json?ns=patryk-newest-rtdb-eu&sse=true
< Access-Control-Allow-Origin: *
< Strict-Transport-Security: max-age=31556926; includeSubDomains; preload