Advertisement
Guest User

Untitled

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