Skip to content

Latest commit

 

History

History

Examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Examples

This folder includes a couple of Examples for AsyncHTTPClient. You can run them by opening the Package.swift in this folder through Xcode. In Xcode you can then select the scheme for the example you want run e.g. GetHTML.

You can also run the examples from the command line by executing the follow command in this folder:

swift run GetHTML

To run other examples you can just replace GetHTML with the name of the example you want to run.

This examples sends a HTTP GET request to https://apple.com/ and first awaits and prints the HTTP Response Head. Afterwards it buffers the full response body in memory and prints the response as a String.

This examples sends a HTTP GET request to https://xkcd.com/info.0.json and first awaits and prints the HTTP Response Head. Afterwards it buffers the full response body in memory, decodes the buffer using a JSONDecoder and dumps the decoded response.

This examples sends a HTTP GET request to https://apple.com/ and first awaits and prints the HTTP Response Head. Afterwards it asynchronously iterates over all body fragments, counts the received bytes and prints a progress indicator (if the server send a content-length header). At the end the total received bytes are printed. Note that we drop all received fragment and therefore do not buffer the whole response body in-memory.