apocas / docker-modem

Docker Remote API network stack driver.
Apache License 2.0
234 stars 112 forks source link

Query string parameters are only added if the URL contains a '?' #95

Open markbirbeck opened 6 years ago

markbirbeck commented 6 years ago

For some reason if an options object like this is submitted:

{
  "method":"POST",
  "path":"/v1.37/containers/...blah.../attach",
  "options":{
    "_body":{},
    "_query":{
      "logs":"true",
      "stream":"true",
      "stdin":"false",
      "stdout":"true",
      "stderr":"true"
    }
  },
  "statusCodes":{"101":true,"200":true,"400":true,"404":true,"500":true},
  "isStream":true
}

the parameters in _query are not added to the URL. However, if there is a question mark in the URL (in path), they are added:

{
  "method":"POST",
  "path":"/v1.37/containers/...blah.../attach?",
  "options":{
    "_body":{},
    "_query":{
      "logs":"true",
      "stream":"true",
      "stdin":"false",
      "stdout":"true",
      "stderr":"true"
    }
  },
  "statusCodes":{"101":true,"200":true,"400":true,"404":true,"500":true},
  "isStream":true
}

The line that causes this is modem.js#L115, but I'm wary of touching it since I'm not quite sure what the logic was.

apocas commented 5 years ago

This comes from way back. At the time the Docker API was very young. There were endpoints sending/posting data in very different ways and different signatures everywhere. Question mark was used in order to easily identify which ones used query string :)

lyleunderwood commented 5 years ago

Spent a bunch of time tracking this down today. Is this still relevant to the docker API?