After writing Java code for so long, my knowledge of network programming is still limited to simply using the Network request framework. Speaking of network programming knowledge points, it seems that most things also know, but seems to know the meaning of a proper noun. For example, “What’s the URL?” “Urls are uniform resource locators.” “Yeah? Finished?” “It’s a proper noun.” “…”
Another example: “Do you know HTTP?” “Oh, this, I know, hypertext Transfer protocol.” “Huh? Anything else?” “…” “What about HTTPS?” “This is a secure hypertext transfer protocol.”
Network programming, to put it bluntly, is a call/interaction resource with the server, which is actually very simple to say, and seems to be very simple to use. Here is the code for a network request automatically generated using PostMan, which is basically the same as the code in our project.
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("http://gank.io/api/history/content/2/1")
.get()
.addHeader("cache-control"."no-cache")
.addHeader("postman-token"."c9b415ce-4a35-097c-1a53-b12d526d8d97")
.build();
Response response = client.newCall(request).execute();Copy the code
This process is really easy, because this is a totally wrapped OkHttp, so the question is, what do these parameters really mean? In what format are parameters uploaded to the server? How did the server respond? What format is the data that the server responds to? Cache, Token, performance optimization, exception handling? Today, I would like to discuss these issues with you. Before we explore these questions, we need to do some preparatory work. First, let’s learn a few things.
- Internet address
- The URL and URI
- HTTP
- URLConnection
- HttpURLConnection
Internet address
IP is the abbreviation of Internet Protocol (Network Protocol). This topic is too big. Let’s briefly understand the Internet address.
We regard all devices connected to the Internet as a node, and computer nodes are called hosts. Each node or host is identified by at least one unique number, which is called an Internet address, or what we call an IP address.
IPv4 and IPv6
That’s a 4-byte IP address and a 6-byte IP address. IPv6 has not yet been introduced worldwide. Remember that IPv6 was introduced because IPv4 addresses were in short supply. For example, 61.135.169.121 is the IP address of baidu home server.
Domain name resolution DNS
As I said just now, 61.135.169.121 is the address of Baidu server, but we use www.baidu.com when we visit Baidu. This website is called the domain name, and usually we use this domain name to visit baidu. During the access, the system searches for IP address 61.135.169.121 corresponding to the domain name www.baidu.com on the DNS server and accesses the server using the IP address.
InetAddress
The java.net.InetAddress class is Java’s high-level representation of IP addresses, including V4 and v6. Most other networks use this class, including Socket, ServerSocket, URP, DatagramSocket, DatagramPacket, and so on. Generally, it consists of a host name and an IP address. I won’t go into details about the API, but if you have any problems with IP addresses, you can always go to this class. The subclass implementations are Inet4Address and Inet6Address. For the most part, we don’t have to worry about V4 or V6, because V6 isn’t popular yet. Java handles v4 or V6 for us at the code level, and as the application layer (the top layer of the OSI model) we don’t need to care.
The URL and URI
Above we saw how the street can determine the address of a host on the Internet from its host name and IP address (essentially the API that calls InetAddress). Here we continue to learn how to address resources.
HTML is a hypertext markup language because it provides a way to know where the URL identifies links to other documents. A URL uniquely identifies a resource’s location on the Internet. The URL is the most common URI (Uniform Resource Identifier). A URI can identify a resource by its network location, name, number, or other characteristics.
The URL class is the easiest way for Java programs to locate and retrieve data on the network. You don’t need to worry about the details of the protocols used or how to communicate with Wu Fuqi. Just tell Java the URL and it will get the data for you.
The difference between URIs and urls
A Uniform Resource Identifier (URI) is a rule that uniquely identifies a resource. In the case of people, assuming that no one in the world has the same name, a name is an instance of a URI, and a unique person can be identified by the string name. In real life, of course, names repeat, so the ID number is the URI, which allows us to identify one person and only one person. So what is a Uniform Resource Locator URL? Also take the human example and then compare with the HTTP URL, you can have: animal address agreement :// Earth/China/Zhejiang province/Hangzhou/Xihu District/some university/Dormitory 14 / dormitory 525 / Zhang SAN. As you can see, this string also identifies a unique person and acts as a URI, so the URL is a subset of the URI. A URL uniquely identifies a person by describing their location. We can also uniquely identify a person by using the id number above. For Zhang SAN in Hangzhou, we can also use id number: 123456789 to identify him. So we can uniquely identify a person either by location or by numbering, which is an implementation of a URI, and a URL is a URI implemented by location. Back on the Web, assume that all Html documents have a unique number called Html: XXXXX. XXXXX is a string of numbers, the ID number of an Html document, that uniquely identifies an Html document, and that number is a URI. A URL is a URI that uniquely identifies a resource by describing which file is on which host and which path. I prefer to call it a URL because it provides information about the location of the resource. If one day the URL is identified by number and becomes http://741236985.html, it would be more appropriate to call it a URI, but in this case, I still have to find the resource.
Above, excerpts from self-knowledge. Next, let’s look at the API for urls and URIs
URI
Here are nine important fields from the URI source code
private transient String scheme; Private TRANSIENT String fragment; Private TRANSIENT String authority; // Authorization private TRANSIENT String userInfo; // User information private TRANSIENT String host; // host private TRANSIENT int port = -1; // Port private TRANSIENT String PATH; // Path private TRANSIENT String query; // Query private VOLATILE TRANSIENT String schemeSpecificPart; / / fragmentCopy the code
If you still don’t understand what a URI is, it’s basically a decomposition of a String address into specific properties. Take a look at the picture below
URL
Just look at the picture
The API of URL is basically similar to URI, mostly constructor and get, set method of each field. But there’s one thing we need to be careful about.
- public URLConnection openConnection()
URL can create a communication link directly based on the parameters we pass, let’s take a quick look at how to create.
public URLConnection openConnection() throws java.io.IOException {
return handler.openConnection(this);
}Copy the code
Find handler in the URL class with the following code:
if (handler == null) {
try {
if (protocol.equals("file")) {
handler = (URLStreamHandler)Class.forName("sun.net.www.protocol.file.Handler").newInstance();
} else if (protocol.equals("ftp")) {
handler = (URLStreamHandler)Class.forName("sun.net.www.protocol.ftp.Handler").newInstance();
} else if (protocol.equals("jar")) {
handler = (URLStreamHandler)Class.forName("sun.net.www.protocol.jar.Handler").newInstance();
} else if (protocol.equals("http")) {
handler = (URLStreamHandler)Class.forName("com.android.okhttp.HttpHandler").newInstance();
} else if (protocol.equals("https")) {
handler = (URLStreamHandler)Class.forName("com.android.okhttp.HttpsHandler").newInstance(); } } catch (Exception e) { throw new AssertionError(e); }}Copy the code
We’ve created different handlers based on the protocol field, and we can see from the logic that we’ve created HttpHandler, Using an HttpHandler openConnection () method creates a sun.net.www.protocol.http.HttpURLConnection object.
HTTP
Hypertext Transfer Protocol (HTTP) is a standard that defines how a client talks to a server and how data is sent from the server back to the client. Although HTTP is often thought of as a way to transfer HTML files and images embedded within them, it is actually a data format. It can be used to transfer TIFF images, Word documents, EXE files, etc. Here we’ll dive into the background to see what happens when we type http://www.google.com into the address bar and press Enter.
The HTTP protocol
HTTP is the standard protocol for communication between clients and servers. HTTP specifies how the client establishes a connection with the server, how the client requests data from the server, how the server responds to the request, and finally how the connection is closed. HTTP connections use TCP/IP to transfer data. For each request from client to server, there are four steps:
1. By default, the client opens a TCP connection with the server on port 80. Other ports can be specified in the URL. 2. The client sends a message to the server requesting resources in the specified path. The request includes a header and optionally (depending on the nature of the request) a blank line followed by the data for the request. 3. The server sends a response to the client. The response begins with the response code, followed by the header containing the data, a blank line, and the requested document or error message. 4. The server is disconnected.
This is the basic HTTP1.0 process, and in HTTP1.1 and later, multiple requests and responses can be sent in succession over a single TCP connection. That is, steps 1 and 4 are direct, and steps 2 and 3 can be repeated many times. Also, in HTTP1.1, requests and responses can be sent in chunks. This has better scalability.
HTTP Request
Each request and response has the same basic form: a header line, an HTTP header containing element data, an empty line, and then a message body.
The format is as follows:
- Request line, divided into three parts: request method, request address, protocol version
GIF HTTP/1.1 indicates that the logo. GIF file is requested from the /image directory
- Request header, used to pass some additional information
Common common request headers
The name of the | role |
---|---|
Content-Type | Request body type, such as: text/plain, application/json |
Accept | Note The received type can be multiple values separated by commas (,) |
Content-Length | Request body length |
Content-Encoding | The encoding format of the request body, such as Gzip and Deflate |
Accept-Encoding | Tell them the content-encoding we accept |
Catche-Control | The value is no-catche, max-age=xx (xx is an integer, indicating voluntary cache for xx seconds). |
- The identifier at the end of the empty line request header
- Optional message body
That is, three parts, respectively: request line, request header, request body
Request method:
HTTP/1.1 defines eight methods to represent different operations on a request-URI resource: OPTIONS, HEAD, GET, POST, PUT, DELETE, TRACE, and CONNECT
Out of these eight methods, right now we generally only have GET and POST methods.
1. The data submitted by GET is placed after the URL. Split URL and transfer data, parameters are concatenated with &. The size of the data submitted by the GET method is limited to 1024 bytes. The data submitted by the POST method is not limited. 4. When submitting data in Get mode, it may cause security problems.For example, when submitting data in Get mode, the user name and password will appear in the URL. You can obtain the user’s account and password from history.
HTTP Response
When a client makes a request to the server, the server responds with a status that includes: the version of the message protocol, the success or error code, server information, entity meta-information, and the necessary entity content. Depending on the response category, server responses can contain physical content, but not all responses should have physical content.
The structure of the response message is also divided into three parts
- The response status line mainly contains the HTTP version information (generally 1.1) and the status code. The status code for the information is as follows:
Status code | The corresponding information |
---|---|
1xx | Message – The request is accepted and processing continues |
2xx | Used to indicate that the request has been successfully received, processed, |
3xx | Used to indicate a willingness to be permanently redirected to another URL |
4xx | Client error – The request has a syntax error or cannot be implemented |
5xx | Server side error – The server failed to fulfill a valid request |
- Response headers
The response header can also be used to pass some additional information. Common response headers
noun | role |
---|---|
Date | Server date |
Last-Modified | Last modified time |
Transfer-Encoding | The value is generally chunked, which occurs when the length of the response body is uncertain |
Set-cookie | Set the Cookie |
Location | Redirect to another URL |
Server | Background server |
- Response body
The body of the response is the Content we need. Generally, content-Length is used in the corresponding header to specify the Length of the corresponding body, which is easy for the browser to accept. Chunked encoding is also used for the body message with large data volume.
HTTPS
Introduction to the
Hypertext Transfer Protocol over Secure Socket Layer (HTTPS) is a Secure HTTP channel. In a nutshell, it is the Secure version of HTTP. That is, add SSL layer to HTTP, and SECURE Sockets Layer (SSL) is the basis of HTTPS security. Therefore, SSL is required for details of encryption.
The difference between HTTPS and HTTP
1. HTTPS requires you to apply for a certificate from the CA. 2. HTTP is a hypertext transmission protocol, and information is transmitted in plain text. HTTPS is a secure SSL encrypted transport protocol. HTTP and HTTPS are completely different. The former is 80 and the latter is 443. HTTP links are simple and stateless. HTTPS is a network protocol that uses SSL and HTTP to encrypt transmission and authenticate identity. It is more secure than HTTP.
The role of the HTTPS
Its main functions can be divided into two kinds: one is to establish an information security channel, to ensure the security of data transmission; The other is to confirm the authenticity of the website.
1. HTTPS in general means that the server has a certificate. The main purpose is to ensure that the server is what it claims to be, which is the same as point 1; All communication between the server and the client is encrypted. 2. Specifically, it is a symmetric secret key generated by the client, and the secret key is exchanged through the certificate of the server, that is, the handshake process in the general sense. 3. All incoming and outgoing messages are encrypted. Even if a third party intercepted it, it wouldn’t make any sense, because he doesn’t have a secret key, so there’s no point in tampering with it. 4. In some cases, the client is required to have a certificate.
Client certificates are similar to personal information, with a ca-authenticated identity in addition to a username/password. Because personal certificates are generally not simulated by others, so this can further confirm their identity. A few professional versions of personal banks do this, such as U Shield.
I’m not going to talk about SSL, because there are so many things involved.
URLConnection
URLConnection is an abstract class that represents an active connection to a URL-specified resource. URLConnection has two different but related uses. First, it provides more control over interactions with servers, especially HTTP servers, than URL classes do. URLConnection can check the headers sent by the server and respond accordingly. It sets the header field to be used in client requests. Finally, URLConnection can send data to the server using POST, PUT, and other HTTP request methods.
Open the URLConnection
Programs that use the URLConnection class directly follow these basic steps:
1. Construct a URL object. 2. Call openConnection() of this URL object to obtain an URLConnection object corresponding to the URL. (For example, an HTTP request is an HttpURLConnection.) 3. Configure this URLConnection. 4. Read header field 5. Get input stream and read data. 6. Get output stream and write data. 7
Not all of these steps are necessarily performed. For example, if the default setting for a URL is acceptable, step 3 might be skipped. If you only need the server’s data and don’t care about any meta information, or if the protocol doesn’t provide any meta information, skip step 4. If you only want to accept data from the server and not send it to the server, you can skip Step 6. Depending on the protocol, the order of steps 5 and 6 May be reversed or alternate.
The URLConnection class has only one constructor of the protected type.
Protected RULConnection (RUL URL)Copy the code
Therefore, unless you subclass URLConnection to handle the new URL type, you create such an object by calling the openConnection() method of the URL class.
try{
URL u = new URL("http://www.baidu.com");
URLConnection uc = u.openConnection();
}catch(Exception e){
System.out.println(e);
}Copy the code
The URLConnection class is declared abstract. However, all but one method has been implemented. You’ll find it convenient, or perhaps necessary, to override other methods of this class. One method that must be implemented by subclasses is connect(), which establishes a connection to the server and thus depends on the service type (HTTP, FTP, etc.). For example sun.net.www.protocol.http.HttpURLConnection connect () method creates a sun.net.www.http.HttpClient object, he is responsible for connection of the server.
When URLConnection is first constructed, it is unconnected. That is, local and original hosts cannot send and receive data. No SOCkey connects the two hosts. The connect() method establishes a connection between the local and remote hosts (typically using TCP sockets, but possibly through other mechanisms) so that data can be sent and received, however, For getInputStream(), getContent(), getHeaderFiled(), and other methods that require the connection to be opened, they call Connect () if the connection is not already open. As a result, you rarely need to call connect() directly.
Read data from the server
Here are the minimum steps required to retrieve data from a URL using the URLConnection object:
1. Construct a URL object. 2. Call the openConnection() method of this URL object to obtain the corresponding URLConnection. 3. Call the URLConnection getInputStream() method 4. Read the input stream using the usual stream API.
The getInputStream() method returns a generic InputStream that reads and parses data sent by the server. The following example downloads a Web page using URLConnection:
For such a simple input stream as this example, the direct difference between URL and URLConnection is not obvious. The biggest difference between these two classes is:
- URLConnection provides access to HTTP headers
- URLConnection can configure request parameters to be sent to the server
- In addition to reading server data, URLConnection can also write data to the server
Read the first
The HTTP server provides a lot of information in the header that precedes each response. For example, here is a typical HTTP header returned by a server:
Bdpagetype →1 bdQID → 0xEF0ab4FD0001728d bdUserID →0 cache-Control →private Connection → keep-alive content-encoding →gzip The content-type to text/HTML. The charset = utf-8 cxy_all - baidu + 631 df64ada7e1077f47313160f7a4090 date - Thu, 16 Nov 2017 08:20:15 GMT expires, Thu, 16 Nov 2017 08:19:54 GMT P3p →CP=" OTI DSP COR IVA OUR IND COM "Server →BWS/1.1 strict-transport-Security →max-age=172800 Transfer-encoding → Chunked vary → accept-encoding X-powered-by - HPHP x - ua - compatible - IE = Edge, chrome = 1Copy the code
There’s a lot of information here, and HAHA, much of which I don’t know, can be compared to the response header field table I listed above.
URLConnection has several methods for retrieving common response header fields
- GetContentType () gets the MIME content type of the response body
- GetContentLength () gets how many bytes are in the content
- GetContentEncoding () gets the encoding of the content
- GetDate () gets the return time of the content
- GetLastModified () gets the last modification time
- GetExpires () indicates when the document expires and needs to be downloaded again
- GetHeaderField (String name) Gets any field in the header
The cache
Web browsers have been caching pages and images for years. If a logo appears repeatedly on every page of the site, browsers typically load it from a remote server only once, save it in the cache, and reload it from the cache every time they need it, rather than asking the remote server to load it every time they encounter it. Some HTTP headers (including Expires and cache-control) control caching.
By default, it is generally assumed that pages accessed over HTTP using GET can and should be cached. Pages accessed using HTTPS or POST should not be cached. However, the HTTP header can adjust this:
- The Expires header (primarily for HTTP1.0) indicates that the resource representation can be cached until the specified world.
-
The catche-Control header (HTTP1.1) provides a fine-grained caching policy:
- Max-age =[seconds]: indicates the number of seconds between now and before the cache entry expires
- S-maxage =[seconds]: The number of seconds from now until the cache entry expires in the shared cache. Private caches can hold cached items longer
- Public: Can cache an authenticated response. Otherwise, the authenticated response cannot be cached.
- Private: Only delayed user caches can save responses, and shared caches should not.
- No-catch: This strategy works differently from the name. Cached entries can still be cached, but the client revalidates the status of the response with an Etag or last-Modified header each time it is accessed.
-
No-store: no cache at all.
Cache-control overrides Expires if both catch-control and Expires headers are present. The server can send multiple cache-control headers in a header as long as they are not in conflict
-
The last-Modified header indicates the date the resource was Last modified. The client can check this date with a HEAD request, and only when the locally cached copy hits the last-Modified date will it actually perform GET to retrieve the resource.
- The Etag header (HTTP1.1) is the displacement identifier of the resource when it changes. The client can use a HEAD request to check this identifier, and only if the locally cached copy has a different Etag will it actually perform GET to retrieve the resource.
Configure the connection
The URLConnection class has seven protected instance fields that define how clients make requests to the server. These fields include
protected URL url;
protected boolean doInpt = true;
protected boolean doOutput = false;
protected boolean allowUserInteraction = defaultAllowUserInteraction;
protected useCaches = defaultUserCachesl;
protected long ifModifiedSince = 0;
protected boolean connected = false;Copy the code
For example, if doOutput is true, in addition to reading data through URLConnection, it is possible to write data to the server. If useCaches is false, the connection will dye all local caches and reload files from the server.
Because these fields are protected, they can only be read and written using the get and set methods.
These fields can only be modified before URLConnection. For methods that set fields, most will throw an IllegaStateException if the connection is already open when they are called. In general, you can only set the properties of the URLConnection object before the connection is opened.
- protected URL url
The URL field specifies the URL for this URLConnection connection. The constructor sets this field when the URLConnection is created and cannot change it thereafter. You can get the value of this field by calling the getURL() method.
- protected boolean connected
The Boolean field connected is true if the connection is already open, or false if the connection is closed. The initial value is false because the connection is not open when a new URLConnection object is created.
- protected boolean allowUserInteraction
Some URlConnections need to interact with users. For example, a Web browser might require a user name and password. However, many applications cannot assume that there is a real user with whom they can interact. But I don’t think we can use it for Android development.
- protected boolean doInput
URLConnection can be used by a read server, a write server, or both. The protection type Boolean field doInput is true if URLConnection can be used to read, false otherwise. The default value is true.
- protected boolean doOutput
Programs can send output back to the server using URLConnection. For example, if a program needs to use the POST method to send data to the server, it can do so by getting the output stream from URLConnection. The field doOutput is true if URLConnection can be used for writes, false otherwise.
- protected boolean ifModifySince
Many clients retain a cache of previously acquired documents. If the user asks for the same document again, it can be retrieved from the cache. However, the document on the server may change after the last retrieval of this document. The only way to tell if anything has changed is to ask the server. Clients can include an if-modified_since in the HTTP header of a user request. This header includes a date and time. If the document changes after that time, the server sends the document, otherwise it does not happen. Typically, this world is the last time the client gets the document.
- Protectedboolean useCaches
Some clients can fetch documents from the local cache rather than from the server. Applets can access the browser’s cache. Standalone applications can use the java.net.ResponseCache class. If there is a cache, the useCaches variable determines whether it can be used. The default value is true, indicating that caching will be used.
timeout
public void setConnectionTimeout()
Call this method to set the connection timeout.
Configure the CLIENT request HTTP header
An HTTP client (such as a browser) makes a request line and a header to the server.
The server can return different data to the client according to the request information, obtain and set cookies, and authenticate users by password, etc. You can do this by placing different fields in the header of the client send and the server response.
- public void setRequestProperty(String name,String value)
The name and value specified by the setRequestProperty() method add a field to the head of the URLConnection. This method can only be used before the connection is opened. Calling this method repeatedly overwrites the previous field. To add a pair, use the addRequestProperty() method.
There is no fixed list of legal headers. The server will ignore unrecognized headers. HTTP does have some restrictions on the name and value of the header field. For example, names cannot contain whitespace, and values cannot contain any newlines. If a field contains a newline, IllegalArgumentException is thrown.
Writes data to the server
Sometimes you need to write data to URLConnection, for example, using POST to submit a form to the server, or using PUT to upload a file. The getOutputStream() method returns an OutputStream that can be used to write data to the server:
public OutputStream getOutputStream()Copy the code
Since URLConnection does not allow output by default, setDooutput(true) must be called before the input stream is requested. When doOutput is set to true for an HTTP URL, the request method changes from GET to POST.
Guess the MIME media type
- public static String guessContentTypeFromName(String var0)
Judging by the file extension, there is generally no problem
- public static String guessContentTypeFromStream(InputStream var0)
Trying to guess the content type by looking at the first few bytes of the stream is usually not as good a guess as the extension.
HttpURLConnection
Java.net.HttpURLConnection class is the abstract subclass URLConnection. It provides additional methods that are especially helpful when dealing with HTTP RUL. Specifically, it contains methods to get and set request methods, determine whether to redirect, get response codes and messages, and determine whether a proxy server is used.
Request method
When a client contacts a server, the first thing it sends is a request line. Typically, this line starts with GET, followed by the path of the resource that the client wants to retrieve, and the HTTO version.
Typically, the default request method is GET, which can be modified using the following methods
- public void setRequestMethod(String method)
The request methods include GET, POST, HEAD, PUT, DELETE, OPTIONS, TRACE. Normally, we only use GET and POST on Android, but now it seems that background prefers POST.
Disconnect from the server
HTTP1.1 supports persistent connections, allowing a SINGLE TCP socket to send multiple requests and responses. The server does not immediately close the connection because it has sent the last byte of data to the client. That is, if the server connects to the same server again before closing the connection, it reuses the socket. A manual call to the disconnect() method will actively disconnect or close if any streams are still open. But closing the open stream in reverse does not close the connection.
Handling server responses
We introduced the format of the server response earlier, so we won’t go over it here.
- GetResponseCode () obtains the response status code
- GetResponseMessage () gets the text string following the response code
redirect
Responses at level 300 represent some kind of redirection, that is, the requested resource is no longer expected, but may be found elsewhere. When you get such a response, most browsers automatically load the document from the new location.
By default, HTTPURLConnection follows a redirection, but HTTPURLConnection has two static methods to control whether to follow a redirection.
- public static boolean getFollowRedirects()
- public static void steFollowRedirects(boolean follow)
Note that this is a static method, global modification.
conclusion
Maybe this chapter is messy, in fact, I am also very desperate, many things I learned while recording, this is the third edition of notes.
The learn the main purpose is to for the HTTP request to have a general understanding of, a lot of knowledge points are one has brought (also ignores some), the students have to do is to know about this, lesson in the eighteenth, nineteenth, probably I will together with the knowledge we’ve learned, hand rolled a Volley request network architecture.
I’m going to give you a preview of what the Volley will accomplish and what the knowledge will be.
Implemented requirements
- Support request JSON text typology, audio, image type, batch download. Upload ~
- When requesting various data, the calling layer does not care about the encapsulation of upload parameters
- Once the data is retrieved, the calling layer does not care about parsing the JSON data
- When calling back, the calling layer only needs to know the corresponding response class of the incoming JSON
- The result of the callback response occurs on the main thread (thread switch)
- To download, upload the extension
- Supports high concurrency requests. The request queue is obtained at a time. You can set the maximum number of concurrent requests
I’m going to use
- The generic
- The request queue
- Blocking queue
- Thread rejection policy
Design patterns used
- Template method pattern
- The singleton pattern
- The strategy pattern
- Producer-consumer mode (not part of the 23 basic haha consumption modes)