Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ! ruby-2.2.3 ~/C/O/clog sys_worker *… crystal put.cr Wed Oct 21 21:59:30 BST 2015
- Error in ./put.cr:8: instantiating 'HTTP::Client#put(String?, Nil, String)'
- res = client.put url.path, nil, payload.to_json
- ^~~
- in macro 'macro_4542132896' /usr/local/Cellar/crystal-lang/0.9.0/src/http/client/client.cr:183, line 115:
- 1.
- 2. # Executes a GET request.
- 3. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 4. #
- 5. # ```
- 6. # client = HTTP::Client.new("www.example.com")
- 7. # response = client.get("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 8. # response.body #=> "..."
- 9. # ```
- 10. def get(path, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 11. exec "GET", path, headers, body
- 12. end
- 13.
- 14. # Executes a GET request and yields the response to the block.
- 15. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 16. #
- 17. # ```
- 18. # client = HTTP::Client.new("www.example.com")
- 19. # client.get("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 20. # response.body_io.gets #=> "..."
- 21. # end
- 22. # ```
- 23. def get(path, headers = nil : HTTP::Headers?, body = nil : String?)
- 24. exec "GET", path, headers, body do |response|
- 25. yield response
- 26. end
- 27. end
- 28.
- 29. # Executes a GET request.
- 30. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 31. #
- 32. # ```
- 33. # response = HTTP::Client.get("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 34. # response.body #=> "..."
- 35. # ```
- 36. def self.get(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 37. exec "GET", url, headers, body
- 38. end
- 39.
- 40. # Executes a GET request and yields the response to the block.
- 41. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 42. #
- 43. # ```
- 44. # HTTP::Client.get("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 45. # response.body_io.gets #=> "..."
- 46. # end
- 47. # ```
- 48. def self.get(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?)
- 49. exec "GET", url, headers, body do |response|
- 50. yield response
- 51. end
- 52. end
- 53.
- 54. # Executes a POST request.
- 55. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 56. #
- 57. # ```
- 58. # client = HTTP::Client.new("www.example.com")
- 59. # response = client.post("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 60. # response.body #=> "..."
- 61. # ```
- 62. def post(path, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 63. exec "POST", path, headers, body
- 64. end
- 65.
- 66. # Executes a POST request and yields the response to the block.
- 67. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 68. #
- 69. # ```
- 70. # client = HTTP::Client.new("www.example.com")
- 71. # client.post("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 72. # response.body_io.gets #=> "..."
- 73. # end
- 74. # ```
- 75. def post(path, headers = nil : HTTP::Headers?, body = nil : String?)
- 76. exec "POST", path, headers, body do |response|
- 77. yield response
- 78. end
- 79. end
- 80.
- 81. # Executes a POST request.
- 82. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 83. #
- 84. # ```
- 85. # response = HTTP::Client.post("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 86. # response.body #=> "..."
- 87. # ```
- 88. def self.post(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 89. exec "POST", url, headers, body
- 90. end
- 91.
- 92. # Executes a POST request and yields the response to the block.
- 93. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 94. #
- 95. # ```
- 96. # HTTP::Client.post("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 97. # response.body_io.gets #=> "..."
- 98. # end
- 99. # ```
- 100. def self.post(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?)
- 101. exec "POST", url, headers, body do |response|
- 102. yield response
- 103. end
- 104. end
- 105.
- 106. # Executes a PUT request.
- 107. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 108. #
- 109. # ```
- 110. # client = HTTP::Client.new("www.example.com")
- 111. # response = client.put("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 112. # response.body #=> "..."
- 113. # ```
- 114. def put(path, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 115. exec "PUT", path, headers, body
- 116. end
- 117.
- 118. # Executes a PUT request and yields the response to the block.
- 119. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 120. #
- 121. # ```
- 122. # client = HTTP::Client.new("www.example.com")
- 123. # client.put("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 124. # response.body_io.gets #=> "..."
- 125. # end
- 126. # ```
- 127. def put(path, headers = nil : HTTP::Headers?, body = nil : String?)
- 128. exec "PUT", path, headers, body do |response|
- 129. yield response
- 130. end
- 131. end
- 132.
- 133. # Executes a PUT request.
- 134. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 135. #
- 136. # ```
- 137. # response = HTTP::Client.put("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 138. # response.body #=> "..."
- 139. # ```
- 140. def self.put(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 141. exec "PUT", url, headers, body
- 142. end
- 143.
- 144. # Executes a PUT request and yields the response to the block.
- 145. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 146. #
- 147. # ```
- 148. # HTTP::Client.put("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 149. # response.body_io.gets #=> "..."
- 150. # end
- 151. # ```
- 152. def self.put(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?)
- 153. exec "PUT", url, headers, body do |response|
- 154. yield response
- 155. end
- 156. end
- 157.
- 158. # Executes a HEAD request.
- 159. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 160. #
- 161. # ```
- 162. # client = HTTP::Client.new("www.example.com")
- 163. # response = client.head("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 164. # response.body #=> "..."
- 165. # ```
- 166. def head(path, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 167. exec "HEAD", path, headers, body
- 168. end
- 169.
- 170. # Executes a HEAD request and yields the response to the block.
- 171. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 172. #
- 173. # ```
- 174. # client = HTTP::Client.new("www.example.com")
- 175. # client.head("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 176. # response.body_io.gets #=> "..."
- 177. # end
- 178. # ```
- 179. def head(path, headers = nil : HTTP::Headers?, body = nil : String?)
- 180. exec "HEAD", path, headers, body do |response|
- 181. yield response
- 182. end
- 183. end
- 184.
- 185. # Executes a HEAD request.
- 186. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 187. #
- 188. # ```
- 189. # response = HTTP::Client.head("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 190. # response.body #=> "..."
- 191. # ```
- 192. def self.head(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 193. exec "HEAD", url, headers, body
- 194. end
- 195.
- 196. # Executes a HEAD request and yields the response to the block.
- 197. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 198. #
- 199. # ```
- 200. # HTTP::Client.head("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 201. # response.body_io.gets #=> "..."
- 202. # end
- 203. # ```
- 204. def self.head(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?)
- 205. exec "HEAD", url, headers, body do |response|
- 206. yield response
- 207. end
- 208. end
- 209.
- 210. # Executes a DELETE request.
- 211. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 212. #
- 213. # ```
- 214. # client = HTTP::Client.new("www.example.com")
- 215. # response = client.delete("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 216. # response.body #=> "..."
- 217. # ```
- 218. def delete(path, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 219. exec "DELETE", path, headers, body
- 220. end
- 221.
- 222. # Executes a DELETE request and yields the response to the block.
- 223. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 224. #
- 225. # ```
- 226. # client = HTTP::Client.new("www.example.com")
- 227. # client.delete("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 228. # response.body_io.gets #=> "..."
- 229. # end
- 230. # ```
- 231. def delete(path, headers = nil : HTTP::Headers?, body = nil : String?)
- 232. exec "DELETE", path, headers, body do |response|
- 233. yield response
- 234. end
- 235. end
- 236.
- 237. # Executes a DELETE request.
- 238. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 239. #
- 240. # ```
- 241. # response = HTTP::Client.delete("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 242. # response.body #=> "..."
- 243. # ```
- 244. def self.delete(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 245. exec "DELETE", url, headers, body
- 246. end
- 247.
- 248. # Executes a DELETE request and yields the response to the block.
- 249. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 250. #
- 251. # ```
- 252. # HTTP::Client.delete("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 253. # response.body_io.gets #=> "..."
- 254. # end
- 255. # ```
- 256. def self.delete(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?)
- 257. exec "DELETE", url, headers, body do |response|
- 258. yield response
- 259. end
- 260. end
- 261.
- 262. # Executes a PATCH request.
- 263. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 264. #
- 265. # ```
- 266. # client = HTTP::Client.new("www.example.com")
- 267. # response = client.patch("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 268. # response.body #=> "..."
- 269. # ```
- 270. def patch(path, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 271. exec "PATCH", path, headers, body
- 272. end
- 273.
- 274. # Executes a PATCH request and yields the response to the block.
- 275. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 276. #
- 277. # ```
- 278. # client = HTTP::Client.new("www.example.com")
- 279. # client.patch("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 280. # response.body_io.gets #=> "..."
- 281. # end
- 282. # ```
- 283. def patch(path, headers = nil : HTTP::Headers?, body = nil : String?)
- 284. exec "PATCH", path, headers, body do |response|
- 285. yield response
- 286. end
- 287. end
- 288.
- 289. # Executes a PATCH request.
- 290. # The response will have its body as a `String`, accessed via `HTTP::Response#body`.
- 291. #
- 292. # ```
- 293. # response = HTTP::Client.patch("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!")
- 294. # response.body #=> "..."
- 295. # ```
- 296. def self.patch(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?) : HTTP::Response
- 297. exec "PATCH", url, headers, body
- 298. end
- 299.
- 300. # Executes a PATCH request and yields the response to the block.
- 301. # The response will have its body as an `IO` accessed via `HTTP::Response#body_io`.
- 302. #
- 303. # ```
- 304. # HTTP::Client.patch("/", headers: HTTP::Headers{"User-agent": "AwesomeApp"}, body: "Hello!") do |response|
- 305. # response.body_io.gets #=> "..."
- 306. # end
- 307. # ```
- 308. def self.patch(url : String | URI, headers = nil : HTTP::Headers?, body = nil : String?)
- 309. exec "PATCH", url, headers, body do |response|
- 310. yield response
- 311. end
- 312. end
- 313.
- exec "PUT", path, headers, body
- ^~~~
- instantiating 'exec(String, String?, Nil, String)'
- in /usr/local/Cellar/crystal-lang/0.9.0/src/http/client/client.cr:328: instantiating 'new_request(String, String?, Nil, String)'
- exec new_request method, path, headers, body
- ^~~~~~~~~~~
- in /usr/local/Cellar/crystal-lang/0.9.0/src/http/client/client.cr:386: instantiating 'HTTP::Headers#[]=(String, String?)'
- headers["Host"] ||= host_header
- ^~
- in macro 'method_missing' expanded macro: forward_missing_to:1, line 1:
- 1. @hash.[]=(_arg0, _arg1)
- 2.
- @hash.[]=(_arg0, _arg1)
- ^~
- no overload matches 'Hash(HTTP::Headers::Key, Array(String))#[]=' with types String, String?
- Overloads are:
- - Hash(HTTP::Headers::Key, Array(String))#[]=(key : HTTP::Headers::Key, value : Array(String))
- ! ruby-2.2.3 ~/C/O/clog sys_worker *… Wed Oct 21 21:59:37 BST 2015
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement