Skip to content

Instantly share code, notes, and snippets.

@tomohisa
Last active May 1, 2016 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomohisa/e32206ca65adda28abc6fc6200ce9808 to your computer and use it in GitHub Desktop.
Save tomohisa/e32206ca65adda28abc6fc6200ce9808 to your computer and use it in GitHub Desktop.
Question about ZEWO 0.5 HTTPS Client
import HTTPSClient
print("Hello, world!")
do {
let client = try Client(host:"slack.com",port:443)
var response : Response = try client.get("/api/api.test?token=SET_YOUR_TOKEN")
print("\(response)")
let buffer = response.body.buffer!
print("\(buffer)")
} catch let error {
print("\(error)")
}
import HTTPSClient
print("Hello, world!")
do {
let client = try Client(uri:URI(host:"slack.com",port:443))
var response : Response = try client.get("/api/api.test?token=SET_YOUR_TOKEN")
print("\(response)")
let buffer = try response.body.becomeBuffer()
print("\(buffer)")
} catch let error {
print("\(error)")
}

HTTPSClient with Zewo 0.5 bad connection.

I am testing my Zewo 0.3 Project with Zewo 0.5

OSX El Capitan. Using bash, each snapshot installed

Using 0.3 with DEVELOPMENT-SNAPSHOT-2016-02-08-a

Using 0.5 with DEVELOPMENT-SNAPSHOT-2016-04-12-a

Both make it build and run

0.5 results

.build/debug/zewo050https
Hello, world!
Response(version: S4.Version(major: 1, minor: 1), status: S4.Status.other(400, "Bad Request"), headers: S4.Headers(headers: [Connection: S4.Header(values: ["close"]), X-Amz-Cf-Id: S4.Header(values: ["E6rZgs5ILkwjVOKmNrja078LeSEmRbu8NL51yhlbMaerKHrCVRTqeg=="]), X-Cache: S4.Header(values: ["Error from cloudfront"]), Server: S4.Header(values: ["CloudFront"]), Via: S4.Header(values: ["1.1 04ad4dd44cc71948e73ac52ffdeebc8a.cloudfront.net (CloudFront)"]), Date: S4.Header(values: ["Thu, 21 Apr 2016 09:14:02 GMT"]), Content-Type: S4.Header(values: ["text/html"]), Content-Length: S4.Header(values: ["551"])]), body: S4.Body.buffer(3c21 444f 4354 5950 4520 4854 4d4c 2050 5542 4c49 4320 222d 2f2f 5733 432f 2f44 5444 2048 544d 4c20 342e 3031 2054 7261 6e73 6974 696f 6e61 6c2f 2f45 4e22 2022 6874 7470 3a2f 2f77 7777 2e77 332e 6f72 672f 5452 2f68 746d 6c34 2f6c 6f6f 7365 2e64 7464 223e 0a3c 4854 4d4c 3e3c 4845 4144 3e3c 4d45 5441 2048 5454 502d 4551 5549 563d 2243 6f6e 7465 6e74 2d54 7970 6522 2043 4f4e 5445 4e54 3d22 7465 7874 2f68 746d 6c3b 2063 6861 7273 6574 3d69 736f 2d38 3835 392d 3122 3e0a 3c54 4954 4c45 3e45 5252 4f52 3a20 5468 6520 7265 7175 6573 7420 636f 756c 6420 6e6f 7420 6265 2073 6174 6973 6669 6564 3c2f 5449 544c 453e 0a3c 2f48 4541 443e 3c42 4f44 593e 0a3c 4831 3e45 5252 4f52 3c2f 4831 3e0a 3c48 323e 5468 6520 7265 7175 6573 7420 636f 756c 6420 6e6f 7420 6265 2073 6174 6973 6669 6564 2e3c 2f48 323e 0a3c 4852 206e 6f73 6861 6465 2073 697a 653d 2231 7078 223e 0a42 6164 2072 6571 7565 7374 2e0a 3c42 5220 636c 6561 723d 2261 6c6c 223e 0a3c 4852 206e 6f73 6861 6465 2073 697a 653d 2231 7078 223e 0a3c 5052 453e 0a47 656e 6572 6174 6564 2062 7920 636c 6f75 6466 726f 6e74 2028 436c 6f75 6446 726f 6e74 290a 5265 7175 6573 7420 4944 3a20 4536 725a 6773 3549 4c6b 776a 564f 4b6d 4e72 6a61 3037 384c 6553 456d 5262 7538 4e4c 3531 7968 6c62 4d61 6572 4b48 7243 5652 5471 6567 3d3d 0a3c 2f50 5245 3e0a 3c41 4444 5245 5353 3e0a 3c2f 4144 4452 4553 533e 0a3c 2f42 4f44 593e 3c2f 4854 4d4c 3e), storage: [:])
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: E6rZgs5ILkwjVOKmNrja078LeSEmRbu8NL51yhlbMaerKHrCVRTqeg==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

But 0.3 worked fine

.build/debug/zewo030https
Hello, world!
HTTP/1.1 200 OK
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Content-Type: application/json; charset=utf-8
X-Amz-Cf-Id: IgYtWT44sp5sAU5G5ZR0fRUnov5J14bnYSkub3SlSkY2IgFFzQefIg==
Vary: Accept-Encoding
Date: Thu, 21 Apr 2016 14:48:19 GMT
Content-Security-Policy: referrer no-referrer;
Pragma: no-cache
X-OAuth-Scopes: identify,read,post,client,apps
Via: 1.1 45fd5b8af901a90c70a650138c35291c.cloudfront.net (CloudFront)
Access-Control-Allow-Origin: *
Cache-Control: private, no-cache, no-store, must-revalidate
X-XSS-Protection: 0
Server: Apache
Transfer-Encoding: chunked
Connection: close
Expires: Mon, 26 Jul 1997 05:00:00 GMT
X-Cache: Miss from cloudfront
X-Content-Type-Options: nosniff

{"ok":true,"args":{"token":"xoxp-15501035636-31291610038-36556570676-fde9952e71"}}
{"ok":true,"args":{"token":"xoxp-15501035636-31291610038-36556570676-fde9952e71"}}

Do anyone know why its happening?

I am attached zipped both project with zewo slack token ;p

$ make clean build 

can execute program if you have all installed https://dl.dropboxusercontent.com/u/1157820/0305.zip

resuest in 0.3

GET /api/api.test?token=xoxp-15501035636-31291610038-36556570676-fde9952e71 HTTP/1.1
Content-Length: 0
User-Agent: Zewo
Host: slack.com:443
Connection: close
Cookie:

-

request in 0.5

Request(method: GET, uri: /api/api.test?token=xoxp-15501035636-31291610038-36556570676-fde9952e71, version: S4.Version(major: 1, minor: 1), headers: S4.Headers(headers: [Content-Length: S4.Header(values: ["0"]), Connection: S4.Header(values: ["close"]), User-Agent: S4.Header(values: ["Zewo"]), Host: S4.Header(values: ["slack.com:443"])]), body: S4.Body.buffer(), storage: [:])
Response(version: S4.Version(major: 1, minor: 1), status: S4.Status.other(400, "Bad Request"), headers: S4.Headers(headers: [Connection: S4.Header(values: ["close"]), X-Amz-Cf-Id: S4.Header(values: ["tzw-MQIVwKB_oi5Zw1nwB9PiaXtPwQ6a_OA7pMJ6ieEBakxTcYloaA=="]), X-Cache: S4.Header(values: ["Error from cloudfront"]), Server: S4.Header(values: ["CloudFront"]), Via: S4.Header(values: ["1.1 c292a111f9c647cf9b2b917e4d8225b6.cloudfront.net (CloudFront)"]), Date: S4.Header(values: ["Fri, 22 Apr 2016 08:50:00 GMT"]), Content-Type: S4.Header(values: ["text/html"]), Content-Length: S4.Header(values: ["551"])]), body: S4.Body.buffer(3c21 444f 4354 5950 4520 4854 4d4c 2050 5542 4c49 4320 222d 2f2f 5733 432f 2f44 5444 2048 544d 4c20 342e 3031 2054 7261 6e73 6974 696f 6e61 6c2f 2f45 4e22 2022 6874 7470 3a2f 2f77 7777 2e77 332e 6f72 672f 5452 2f68 746d 6c34 2f6c 6f6f 7365 2e64 7464 223e 0a3c 4854 4d4c 3e3c 4845 4144 3e3c 4d45 5441 2048 5454 502d 4551 5549 563d 2243 6f6e 7465 6e74 2d54 7970 6522 2043 4f4e 5445 4e54 3d22 7465 7874 2f68 746d 6c3b 2063 6861 7273 6574 3d69 736f 2d38 3835 392d 3122 3e0a 3c54 4954 4c45 3e45 5252 4f52 3a20 5468 6520 7265 7175 6573 7420 636f 756c 6420 6e6f 7420 6265 2073 6174 6973 6669 6564 3c2f 5449 544c 453e 0a3c 2f48 4541 443e 3c42 4f44 593e 0a3c 4831 3e45 5252 4f52 3c2f 4831 3e0a 3c48 323e 5468 6520 7265 7175 6573 7420 636f 756c 6420 6e6f 7420 6265 2073 6174 6973 6669 6564 2e3c 2f48 323e 0a3c 4852 206e 6f73 6861 6465 2073 697a 653d 2231 7078 223e 0a42 6164 2072 6571 7565 7374 2e0a 3c42 5220 636c 6561 723d 2261 6c6c 223e 0a3c 4852 206e 6f73 6861 6465 2073 697a 653d 2231 7078 223e 0a3c 5052 453e 0a47 656e 6572 6174 6564 2062 7920 636c 6f75 6466 726f 6e74 2028 436c 6f75 6446 726f 6e74 290a 5265 7175 6573 7420 4944 3a20 747a 772d 4d51 4956 774b 425f 6f69 355a 7731 6e77 4239 5069 6158 7450 7751 3661 5f4f 4137 704d 4a36 6965 4542 616b 7854 6359 6c6f 6141 3d3d 0a3c 2f50 5245 3e0a 3c41 4444 5245 5353 3e0a 3c2f 4144 4452 4553 533e 0a3c 2f42 4f44 593e 3c2f 4854 4d4c 3e), storage: [:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment