An example of simple HTTP SSL POST request
Motivation
- easy integration into ctrs
Features
- open source development environment and dependencies
- kiss (keep it stupid simple) : minimal code
- non blocking multithread I/O
- linux and macOS compatible
- library and command line executable
Dependencies
- Foundation, SwiftNIO, SwiftNIOSSL
Development tools
- VSCode
- LLDB
- Sourcekit-LSP
Testing platforms
- macOS 10.15
- Linux Ubuntu 18.04.
$ swift build -c release
$ ./.build/release/filepost
Use : $ filepost <bodyFile> [url] [certFile] [keyFile] [trustRootFile]
Example : $ filepost myTextFile https://localhost:8888
Test, send a file to https://google.com :
$ echo "meilleurs voeux" > myFile.txt
$ ./.build/release/filepost myFile.txt https://google.com
Starting filepost body:myFile.txt, url:https://google.com, cert:[], key:nil, trustRoot:default
moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>405.</b> <ins>That’s an error.</ins>
<p>The request method <code>POST</code> is inappropriate for the URL <code>/</code>. <ins>That’s all we know.</ins>
In a swift program :
try HTTPSPoster().post(url: url, body: body, cert: cert, key: key, trustRoot: trustRoot)
VSCode files are located in the .vscode
directory.
They provide launch and task configurations for debug and test.
These configurations can be used with "Native Debug" or "CodeLLDB" extensions.
$ swift test