docker-modem icon indicating copy to clipboard operation
docker-modem copied to clipboard

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

Open markbirbeck opened this issue 7 years ago • 2 comments

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.

markbirbeck avatar Aug 10 '18 23:08 markbirbeck

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 :)

apocas avatar Sep 23 '19 19:09 apocas

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

lyleunderwood avatar Nov 08 '19 20:11 lyleunderwood