| 385 | NO_CALLBACK() |
| 386 | |
| 387 | def test_from_curl(self): |
| 388 | # Note: more curated tests regarding curl conversion are in |
| 389 | # `test_utils_curl.py` |
| 390 | curl_command = ( |
| 391 | "curl 'http://httpbin.org/post' -X POST -H 'Cookie: _gauges_unique" |
| 392 | "_year=1; _gauges_unique=1; _gauges_unique_month=1; _gauges_unique" |
| 393 | "_hour=1; _gauges_unique_day=1' -H 'Origin: http://httpbin.org' -H" |
| 394 | " 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q" |
| 395 | "=0.9,ru;q=0.8,es;q=0.7' -H 'Upgrade-Insecure-Requests: 1' -H 'Use" |
| 396 | "r-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTM" |
| 397 | "L, like Gecko) Ubuntu Chromium/62.0.3202.75 Chrome/62.0.3202.75 S" |
| 398 | "afari/537.36' -H 'Content-Type: application /x-www-form-urlencode" |
| 399 | "d' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=" |
| 400 | "0.9,image/webp,image/apng,*/*;q=0.8' -H 'Cache-Control: max-age=0" |
| 401 | "' -H 'Referer: http://httpbin.org/forms/post' -H 'Connection: kee" |
| 402 | "p-alive' --data 'custname=John+Smith&custtel=500&custemail=jsmith" |
| 403 | "%40example.org&size=small&topping=cheese&topping=onion&delivery=1" |
| 404 | "2%3A15&comments=' --compressed" |
| 405 | ) |
| 406 | r = self.request_class.from_curl(curl_command) |
| 407 | assert r.method == "POST" |
| 408 | assert r.url == "http://httpbin.org/post" |
| 409 | assert ( |
| 410 | r.body == b"custname=John+Smith&custtel=500&custemail=jsmith%40" |
| 411 | b"example.org&size=small&topping=cheese&topping=onion" |
| 412 | b"&delivery=12%3A15&comments=" |
| 413 | ) |
| 414 | assert r.cookies == { |
| 415 | "_gauges_unique_year": "1", |
| 416 | "_gauges_unique": "1", |
| 417 | "_gauges_unique_month": "1", |
| 418 | "_gauges_unique_hour": "1", |
| 419 | "_gauges_unique_day": "1", |
| 420 | } |
| 421 | assert r.headers == { |
| 422 | b"Origin": [b"http://httpbin.org"], |
| 423 | b"Accept-Encoding": [b"gzip, deflate"], |
| 424 | b"Accept-Language": [b"en-US,en;q=0.9,ru;q=0.8,es;q=0.7"], |
| 425 | b"Upgrade-Insecure-Requests": [b"1"], |
| 426 | b"User-Agent": [ |
| 427 | b"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537." |
| 428 | b"36 (KHTML, like Gecko) Ubuntu Chromium/62.0.3202" |
| 429 | b".75 Chrome/62.0.3202.75 Safari/537.36" |
| 430 | ], |
| 431 | b"Content-Type": [b"application /x-www-form-urlencoded"], |
| 432 | b"Accept": [ |
| 433 | b"text/html,application/xhtml+xml,application/xml;q=0." |
| 434 | b"9,image/webp,image/apng,*/*;q=0.8" |
| 435 | ], |
| 436 | b"Cache-Control": [b"max-age=0"], |
| 437 | b"Referer": [b"http://httpbin.org/forms/post"], |
| 438 | b"Connection": [b"keep-alive"], |
| 439 | } |
| 440 | |
| 441 | def test_from_curl_with_kwargs(self): |
| 442 | r = self.request_class.from_curl( |