remove hardcoded browserchannel protocol version number
This commit is contained in:
parent
5056d14d3a
commit
472a551606
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(def protocol-version 8)
|
||||||
|
|
||||||
(def ^:private noop-string "[\"noop\"]")
|
(def ^:private noop-string "[\"noop\"]")
|
||||||
|
|
||||||
;; almost all special cases are for making this work with IE
|
;; almost all special cases are for making this work with IE
|
||||||
|
@ -670,8 +672,8 @@
|
||||||
;; and if the connection can support streaming
|
;; and if the connection can support streaming
|
||||||
(defn- handle-test-channel
|
(defn- handle-test-channel
|
||||||
[req options]
|
[req options]
|
||||||
(if-not (= "8" (get-in req [:query-params "VER"]))
|
(if-not (= (str protocol-version) (get-in req [:query-params "VER"]))
|
||||||
(error-response 400 "Version 8 required")
|
(error-response 400 (str "Version " protocol-version " required"))
|
||||||
;; phase 1
|
;; phase 1
|
||||||
;; client requests [random host-prefix or
|
;; client requests [random host-prefix or
|
||||||
;; nil,blockedPrefix]
|
;; nil,blockedPrefix]
|
||||||
|
@ -709,7 +711,7 @@
|
||||||
;; first post after a new session is a message with the session
|
;; first post after a new session is a message with the session
|
||||||
;; details.
|
;; details.
|
||||||
;; response is first array sent for this session:
|
;; response is first array sent for this session:
|
||||||
;; [[0,["c", session-id, host-prefix, version (always 8)]]]
|
;; [[0,["c", session-id, host-prefix, version (always equal to protocol-version)]]]
|
||||||
;; send as json for XHR and IE
|
;; send as json for XHR and IE
|
||||||
(let [session @session-agent
|
(let [session @session-agent
|
||||||
session-id (:id session)
|
session-id (:id session)
|
||||||
|
@ -717,7 +719,7 @@
|
||||||
host-prefix nil]
|
host-prefix nil]
|
||||||
{:status 200
|
{:status 200
|
||||||
:headers (assoc (:headers options) "Content-Type" "application/javascript")
|
:headers (assoc (:headers options) "Content-Type" "application/javascript")
|
||||||
:body (size-json-str (json/generate-string [[0, ["c", session-id, host-prefix, 8]]]))})
|
:body (size-json-str (json/generate-string [[0, ["c", session-id, host-prefix, protocol-version]]]))})
|
||||||
;; For existing sessions:
|
;; For existing sessions:
|
||||||
;; Forward sent data by client to listeners
|
;; Forward sent data by client to listeners
|
||||||
;; reply with
|
;; reply with
|
||||||
|
|
|
@ -40,9 +40,9 @@
|
||||||
resp (app (-> (mock/request
|
resp (app (-> (mock/request
|
||||||
:post "/channel/bind")
|
:post "/channel/bind")
|
||||||
(mock/query-string
|
(mock/query-string
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"RID" 1
|
"RID" 1
|
||||||
"CVER" 8
|
"CVER" protocol-version
|
||||||
"zx" (random-string)
|
"zx" (random-string)
|
||||||
"t" 1}))
|
"t" 1}))
|
||||||
options)]
|
options)]
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
(is (and (string? session-id)
|
(is (and (string? session-id)
|
||||||
(not (string/blank? session-id))))
|
(not (string/blank? session-id))))
|
||||||
(is (nil? host-prefix))
|
(is (nil? host-prefix))
|
||||||
(is (= 8 version))
|
(is (= protocol-version version))
|
||||||
(is (get @sessions session-id))
|
(is (get @sessions session-id))
|
||||||
(is (connected? session-id)))))
|
(is (connected? session-id)))))
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@
|
||||||
(let [resp (app (-> (mock/request
|
(let [resp (app (-> (mock/request
|
||||||
:get "/channel/bind")
|
:get "/channel/bind")
|
||||||
(mock/query-string
|
(mock/query-string
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"RID" "rpc"
|
"RID" "rpc"
|
||||||
"CVER" 8
|
"CVER" protocol-version
|
||||||
"CI" 0
|
"CI" 0
|
||||||
"AID" 0
|
"AID" 0
|
||||||
"TYPE" "xmlhttp"
|
"TYPE" "xmlhttp"
|
||||||
|
@ -78,10 +78,10 @@
|
||||||
(let [resp (app (-> (mock/request
|
(let [resp (app (-> (mock/request
|
||||||
:get "/channel/bind")
|
:get "/channel/bind")
|
||||||
(mock/query-string
|
(mock/query-string
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"RID" "rpc"
|
"RID" "rpc"
|
||||||
"SID" "foobar"
|
"SID" "foobar"
|
||||||
"CVER" 8
|
"CVER" protocol-version
|
||||||
"CI" 0
|
"CI" 0
|
||||||
"AID" 0
|
"AID" 0
|
||||||
"TYPE" "xmlhttp"
|
"TYPE" "xmlhttp"
|
||||||
|
@ -95,9 +95,9 @@
|
||||||
(-> (mock/request
|
(-> (mock/request
|
||||||
:post "/channel/bind")
|
:post "/channel/bind")
|
||||||
(mock/query-string
|
(mock/query-string
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"RID" 1
|
"RID" 1
|
||||||
"CVER" 8
|
"CVER" protocol-version
|
||||||
"zx" (random-string)
|
"zx" (random-string)
|
||||||
"t" 1})))
|
"t" 1})))
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@
|
||||||
back-resp (app (-> (mock/request
|
back-resp (app (-> (mock/request
|
||||||
:get "/channel/bind")
|
:get "/channel/bind")
|
||||||
(mock/query-string
|
(mock/query-string
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"RID" "rpc"
|
"RID" "rpc"
|
||||||
"SID" session-id
|
"SID" session-id
|
||||||
"CVER" 8
|
"CVER" protocol-version
|
||||||
"CI" 0
|
"CI" 0
|
||||||
"AID" 0
|
"AID" 0
|
||||||
"TYPE" "xmlhttp"
|
"TYPE" "xmlhttp"
|
||||||
|
@ -142,10 +142,10 @@
|
||||||
(-> (mock/request
|
(-> (mock/request
|
||||||
:get "/channel/bind")
|
:get "/channel/bind")
|
||||||
(mock/query-string
|
(mock/query-string
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"RID" "rpc"
|
"RID" "rpc"
|
||||||
"SID" session-id
|
"SID" session-id
|
||||||
"CVER" 8
|
"CVER" protocol-version
|
||||||
"CI" 0
|
"CI" 0
|
||||||
"AID" 0
|
"AID" 0
|
||||||
"TYPE" "xmlhttp"
|
"TYPE" "xmlhttp"
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
(deftest get-host-prefixes-test-no-prefixes
|
(deftest get-host-prefixes-test-no-prefixes
|
||||||
(let [resp (app (mock/request
|
(let [resp (app (mock/request
|
||||||
:get "/channel/test"
|
:get "/channel/test"
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"MODE" "init"
|
"MODE" "init"
|
||||||
"zx" (random-string)
|
"zx" (random-string)
|
||||||
"t" 1}))]
|
"t" 1}))]
|
||||||
|
@ -55,7 +55,7 @@
|
||||||
{:host-prefixes ["a", "b", "c"]})
|
{:host-prefixes ["a", "b", "c"]})
|
||||||
resp (app (mock/request
|
resp (app (mock/request
|
||||||
:get "/channel/test"
|
:get "/channel/test"
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"MODE" "init"
|
"MODE" "init"
|
||||||
"zx" (random-string)
|
"zx" (random-string)
|
||||||
"t" 1})
|
"t" 1})
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
(deftest buffering-proxy-test
|
(deftest buffering-proxy-test
|
||||||
(let [resp (app (mock/request
|
(let [resp (app (mock/request
|
||||||
:get "/channel/test"
|
:get "/channel/test"
|
||||||
{"VER" 8
|
{"VER" protocol-version
|
||||||
"zx" (random-string)
|
"zx" (random-string)
|
||||||
"t" 1}))
|
"t" 1}))
|
||||||
async-resp @async-output]
|
async-resp @async-output]
|
||||||
|
|
Reference in a new issue