100% found this document useful (1 vote)
36 views

Instant download Coding Clean, Reliable, and Safe REST APIs with ASP.NET Core 8 1st Edition Anthony Giretti pdf all chapter

APIs

Uploaded by

miehlraquin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
36 views

Instant download Coding Clean, Reliable, and Safe REST APIs with ASP.NET Core 8 1st Edition Anthony Giretti pdf all chapter

APIs

Uploaded by

miehlraquin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download Full Version ebook - Visit ebookmeta.

com

Coding Clean, Reliable, and Safe REST APIs with


ASP.NET Core 8 1st Edition Anthony Giretti

https://ebookmeta.com/product/coding-clean-reliable-and-
safe-rest-apis-with-asp-net-core-8-1st-edition-anthony-
giretti/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmeta.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

Coding Clean, Reliable, and Safe REST APIs with ASP.NET


Core 8: Develop Robust Minimal APIs with .NET 8 Anthony
Giretti
https://ebookmeta.com/product/coding-clean-reliable-and-safe-rest-
apis-with-asp-net-core-8-develop-robust-minimal-apis-with-
net-8-anthony-giretti/
ebookmeta.com

Beginning gRPC with ASP.NET Core 6: Build Applications


using ASP.NET Core Razor Pages, Angular, and Best
Practices in .NET 6 1st Edition Anthony Giretti
https://ebookmeta.com/product/beginning-grpc-with-asp-net-
core-6-build-applications-using-asp-net-core-razor-pages-angular-and-
best-practices-in-net-6-1st-edition-anthony-giretti/
ebookmeta.com

Building Web APIs with ASP.NET Core (MEAP Version 11)


Valerio De Sanctis

https://ebookmeta.com/product/building-web-apis-with-asp-net-core-
meap-version-11-valerio-de-sanctis/

ebookmeta.com

Field Guide to Clandestine Laboratory Identification and


Investigation 2 ed Christian Donnell R. Jr.

https://ebookmeta.com/product/field-guide-to-clandestine-laboratory-
identification-and-investigation-2-ed-christian-donnell-r-jr/

ebookmeta.com
Birds Of Prey Hermann Huppen

https://ebookmeta.com/product/birds-of-prey-hermann-huppen/

ebookmeta.com

Zootechnologies A Media History of Swarm Research 1st


Edition Sebastian Vehlken

https://ebookmeta.com/product/zootechnologies-a-media-history-of-
swarm-research-1st-edition-sebastian-vehlken/

ebookmeta.com

Clinical Neuroembryology: Development and Developmental


Disorders of the Human Central Nervous System Hans J. Ten
Donkelaar
https://ebookmeta.com/product/clinical-neuroembryology-development-
and-developmental-disorders-of-the-human-central-nervous-system-hans-
j-ten-donkelaar/
ebookmeta.com

Geometry for Programmers (MEAP v11) Oleksandr Kaleniuk

https://ebookmeta.com/product/geometry-for-programmers-
meap-v11-oleksandr-kaleniuk/

ebookmeta.com

Given (Bitten and Bound Book 1) 1st Edition Amy Pennza

https://ebookmeta.com/product/given-bitten-and-bound-book-1-1st-
edition-amy-pennza/

ebookmeta.com
Handbook of the Irish Revival : An Anthology of Irish
Cultural and Political Writings 1891-1922 1st Edition
Declan Kiberd
https://ebookmeta.com/product/handbook-of-the-irish-revival-an-
anthology-of-irish-cultural-and-political-writings-1891-1922-1st-
edition-declan-kiberd/
ebookmeta.com
Coding Clean,
Reliable, and Safe
REST APIs with
ASP.NET Core 8
Develop Robust Minimal
APIs with .NET 8

Anthony Giretti
Coding Clean, Reliable, and Safe REST APIs with ASP.NET Core 8:
Develop Robust Minimal APIs with .NET 8
Anthony Giretti
La Salle, QC, Canada

ISBN-13 (pbk): 978-1-4842-9978-4 ISBN-13 (electronic): 978-1-4842-9979-1


https://doi.org/10.1007/978-1-4842-9979-1
Copyright © 2023 by Anthony Giretti
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Smriti Srivastava
Development Editor: Laura Berendson
Editorial Assistant: Gryffin Winkler
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1
New York Plaza, 1 FDR Dr, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for
reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on the Github repository. For more detailed information, please visit
https://www.apress.com/gp/services/source-code.
Paper in this product is recyclable
Table of Contents
About the Author���������������������������������������������������������������������������������ix

About the Technical Reviewer�������������������������������������������������������������xi

Acknowledgments�����������������������������������������������������������������������������xiii

Prerequisites��������������������������������������������������������������������������������������xv

Introduction��������������������������������������������������������������������������������������xvii

Chapter 1: Introducing HTTP and REST�������������������������������������������������1


Unveiling HTTP Behind the Web����������������������������������������������������������������������������1
The Characteristics of HTTP����������������������������������������������������������������������������3
HTTP Requests and Responses�����������������������������������������������������������������������4
HTTP Implementation��������������������������������������������������������������������������������������5
Extend Your Talent on the Web with REST Architecture Style�����������������������������32
REST Constraints�������������������������������������������������������������������������������������������33
REST Good Practices�������������������������������������������������������������������������������������34
Summary������������������������������������������������������������������������������������������������������������41

Chapter 2: Introducing ASP.NET Core 8�����������������������������������������������43


ASP.NET Core Fundamentals�������������������������������������������������������������������������������44
ASP.NET Core Web API�����������������������������������������������������������������������������������������53
ASP.NET Core Minimal APIs���������������������������������������������������������������������������������65
Summary������������������������������������������������������������������������������������������������������������69

iii
Table of Contents

Chapter 3: Introduction to Application Development


Best Practices������������������������������������������������������������������������������������71
Getting the Right Frame of Mind�������������������������������������������������������������������������72
A Basic Understanding of the Business���������������������������������������������������������72
Problem-Solving Skills����������������������������������������������������������������������������������72
Understanding Programming Paradigms������������������������������������������������������73
Logical and Structured Thinking��������������������������������������������������������������������73
Clean Architecture Fundamentals�����������������������������������������������������������������������74
Clean Code Fundamentals����������������������������������������������������������������������������������79
General Coding Fundamentals����������������������������������������������������������������������79
Coding Style Fundamentals���������������������������������������������������������������������������83
OWASP Principles�����������������������������������������������������������������������������������������������86
Summary������������������������������������������������������������������������������������������������������������90

Chapter 4: Basics of Clean REST APIs������������������������������������������������91


Routing with ASP.NET Core 8������������������������������������������������������������������������������92
ASP.NET Core Routing������������������������������������������������������������������������������������92
RouteGroups������������������������������������������������������������������������������������������������103
Parameter Binding��������������������������������������������������������������������������������������������107
What’s Precisely Parameter Binding?���������������������������������������������������������108
Parameter Binding by Example�������������������������������������������������������������������109
Validating Inputs�����������������������������������������������������������������������������������������������119
Object Mapping�������������������������������������������������������������������������������������������������129
Managing CRUD Operations and HTTP Statuses�����������������������������������������������135
Handling HTTP Statuses������������������������������������������������������������������������������136
Creating the Services to Handle CRUD Operations��������������������������������������138
Creating the Endpoints to Handle CRUD Operations������������������������������������141
Downloading and Uploading Files���������������������������������������������������������������������151
Downloading Files���������������������������������������������������������������������������������������151

iv
Table of Contents

Uploading Files��������������������������������������������������������������������������������������������155
Streaming Content��������������������������������������������������������������������������������������������169
Handling CORS��������������������������������������������������������������������������������������������������171
API Versioning���������������������������������������������������������������������������������������������������177
Versioning by Headers���������������������������������������������������������������������������������178
Versioning by Route�������������������������������������������������������������������������������������187
Documenting APIs���������������������������������������������������������������������������������������������190
Managing API Versions in Swagger�������������������������������������������������������������192
Adding Comments on Endpoints�����������������������������������������������������������������199
Grouping Endpoints by Tag��������������������������������������������������������������������������206
Other Customizations����������������������������������������������������������������������������������207
Summary����������������������������������������������������������������������������������������������������������212

Chapter 5: Going Further with Clean REST APIs�������������������������������213


Encapsulating Minimal Endpoint Implementation���������������������������������������������214
Implementing Custom Parameter Binding��������������������������������������������������������219
Example of Custom Parameter Binding from Headers��������������������������������220
Example of Custom Parameter Binding from the From Data�����������������������222
Using Middlewares�������������������������������������������������������������������������������������������225
Using Action Filters�������������������������������������������������������������������������������������������238
Using Rate Limiting�������������������������������������������������������������������������������������������243
The Fixed Window Model�����������������������������������������������������������������������������246
The Sliding Window Model��������������������������������������������������������������������������253
The Token Bucket Model�����������������������������������������������������������������������������255
The Concurrency Model�������������������������������������������������������������������������������257
Global Error Management���������������������������������������������������������������������������������259
Summary����������������������������������������������������������������������������������������������������������266

v
Table of Contents

Chapter 6: Accessing Data Safely and Efficiently�����������������������������267


Introduction to Data Access Best Practices������������������������������������������������������267
SQL-Type Data Access���������������������������������������������������������������������������������268
HTTP Data Access����������������������������������������������������������������������������������������269
Architecturing Data Access�������������������������������������������������������������������������269
Accessing Data with Entity Framework Core 8�������������������������������������������������271
Step 1: Creating the CountryEntity Class�����������������������������������������������������272
Step 2: Creating the EF Core Context����������������������������������������������������������273
Step 3: Configuring the CountryEntity���������������������������������������������������������274
Step 4: Generating the Database Model from C#����������������������������������������276
Step 5: Enabling Resiliency with Entity Framework Core����������������������������280
Step 6: Writing the Repository on Top of the CountryEntity�������������������������281
Accessing Data with HttpClient and REST APIs�������������������������������������������������294
Using IHttpClientFactory to Make HTTP Requests���������������������������������������295
Using Refit to Make HTTP Requests������������������������������������������������������������297
Using Polly to Make HTTP Requests Resilient���������������������������������������������298
Summary����������������������������������������������������������������������������������������������������������301

Chapter 7: Optimizing APIs���������������������������������������������������������������303


Asynchronous Programming�����������������������������������������������������������������������������303
Basics of Asynchronous Programming��������������������������������������������������������304
Using CancellationToken�����������������������������������������������������������������������������306
Long-Running Tasks with Background Services�����������������������������������������������310
Paging���������������������������������������������������������������������������������������������������������������321
JSON Streaming������������������������������������������������������������������������������������������������324
Caching�������������������������������������������������������������������������������������������������������������326
Output Cache�����������������������������������������������������������������������������������������������326
In-Memory Cache����������������������������������������������������������������������������������������330
Distributed Cache����������������������������������������������������������������������������������������336

vi
Table of Contents

Speeding Up HTTP Requests with HTTP/2 and HTTP/3�������������������������������������342


Summary����������������������������������������������������������������������������������������������������������343

Chapter 8: Introduction to Observability������������������������������������������345


Basics of Observability��������������������������������������������������������������������������������������346
Performing Logging������������������������������������������������������������������������������������������347
Performing Tracing and Metrics Data Collection�����������������������������������������������363
Implementing HealthCheck�������������������������������������������������������������������������������367
Liveness HealthCheck���������������������������������������������������������������������������������368
Readiness HealthCheck�������������������������������������������������������������������������������370
Summary����������������������������������������������������������������������������������������������������������374

Chapter 9: Managing Application Secrets����������������������������������������375


Introduction to Application Secret Management�����������������������������������������������375
Example with Azure Key Vault���������������������������������������������������������������������������378
Summary����������������������������������������������������������������������������������������������������������383

Chapter 10: Secure Your Application with OpenID Connect��������������385


Introduction to OpenID Connect������������������������������������������������������������������������386
Configuring Authentication and Authorization in ASP.NET Core������������������������389
Passing a JWT into Requests and Getting the User’s Identity���������������������������395
Summary����������������������������������������������������������������������������������������������������������401

Chapter 11: Testing APIs������������������������������������������������������������������403


Introduction to Testing��������������������������������������������������������������������������������������403
Efficient Unit Testing�����������������������������������������������������������������������������������������405
Using the Right Tools�����������������������������������������������������������������������������������406
Testing a SUT Step-by-Step�������������������������������������������������������������������������408
Summary����������������������������������������������������������������������������������������������������������418

Index�������������������������������������������������������������������������������������������������419

vii
About the Author
Anthony Giretti is a senior developer/architect
at Marchex in Toronto, Canada. He appreciates
learning and teaching new technologies and
has a knack for web technologies (more than
17 years’ experience) and a keen interest in
.NET. His expertise in development and IT and
his passion for sharing his knowledge allow
him to deconstruct any web project in order
to help other developers achieve their project
goals. He loves to deal with performance constraints, high availability,
and optimization challenges. Anthony is the author of Beginning gRPC
with ASP.NET Core 6 (Apress), a six-time Microsoft MVP, and a Microsoft
Certified Software Developer (MCSD).

ix
About the Technical Reviewer
Fiodar Sazanavets is a Microsoft MVP and a
senior software engineer with over a decade
of professional experience. He primarily
specializes in .NET and Microsoft stack and
is enthusiastic about creating well-crafted
software that fully meets business needs.
He enjoys teaching aspiring developers and
sharing his knowledge with the community,
which he has done both as a volunteer and
commercially. Fiodar has created several
online courses, written a number of technical books, and authored other
types of educational content. He also provides live mentoring services,
both to groups and individuals. Throughout his career, he has built
software of various types and various levels of complexity in multiple
industries. This includes a passenger information management system
for a railway, distributed smart clusters of IoT devices, ecommerce
systems, financial transaction processing systems, and more. He has also
successfully led and mentored teams of software developers.

xi
Acknowledgments
Completing this book could not have been possible without the
participation and assistance of many people, and I would like to express
my special thanks to them. First, thanks to my wife, Nadege, who never
stopped supporting me. I love you!
Next, I would like to thank the rest of my family for their support.
This book has been written in special conditions since I was
hospitalized for a severe disease that could have taken my life. I haven’t
given up, and I hope this book will please you; if I have completed it, it’s for
a good reason, I hope!
I also would like to thank my colleagues at Marchex, especially
my friend (and colleague) Callon Campbell, who never stopped
encouraging me.
Thanks to my friend Dominique St-Amand, who has never been stingy
with comments to help me improve this book.
Last but not least, Fiodar Sazanavets! Thanks, my friend, for being part
of this journey; you were essential in this new challenge I set for myself.
Without you, I wouldn’t have succeeded.

xiii
Prerequisites
This book is aimed at beginner and intermediate developers who want to
take their Application Programming Interface (API) development skills to
the next level. In this book, I assume you know the basics of .NET, C#, and,
therefore, the fundamentals of Object-Oriented Programming (OOP). I
also assume you’ve already used Visual Studio and know how to use it. As
for web fundamentals, I’ve started from scratch, so if you don’t know much
about the Web, no problem!

xv
Introduction
Dear reader friend, welcome to this book!
In my career, I have worked in various companies and on various
complex APIs. Although each company had its challenges, I can assure you
that they all had one thing in common: their APIs lacked a lot of love and
care. They all suffered from the same problems: poor code organization
due to an accumulation of minor errors over the years, lack of consistency
in the definition of coding conventions, lack of technological refreshment,
misinterpretations of the HyperText Transfer Protocol (HTTP) and
Representational State Transfer (REST) principles, missing logging or bad
logging practice, and not enough care regarding performances.
I have always enjoyed helping teams overcome these difficulties,
and I have decided to write a book to share my experiences and guide
you through the best practices of API implementations. This book will
focus on some technical architecture of an API, but it will focus more on
coding practices to help you avoid the most common mistakes in your
development career. I will not cover solution architecture where an API
is built around other systems, but keep assured; I will show you how to
implement access to external data sources.
At the end of this book, you will know how to develop APIs with ASP.
NET Core 8 properly coded, performant, resilient, secure, testable, and
debuggable. You will go from a beginner/intermediate level to a senior
level by learning precisely WHAT you need to know without feeling
overwhelmed by a ton of information.

Let’s go!

xvii
CHAPTER 1

Introducing HTTP
and REST
Before we dive into ASP.NET Core 8 and API development, let’s first go
back to the basics of any web application. Whether a website is run from a
browser or a web service (web API), it’s always the same principle: a client
and a server will communicate together; a client will send a request to a
server, which will then respond to the client. This is all possible with the
magic of the HTTP communication protocol. Under this protocol, data
can be transported using different formats and constraints. Here is REST!
REST is an architectural concept of data representation. Of course, these
two should not be confused. In this chapter, we will cover the following
content:

• HTTP

• REST architecture style

Unveiling HTTP Behind the Web


The HyperText Transfer Protocol (HTTP) is a network protocol for
exchanging data between clients and servers. This protocol was invented
in 1990 by British computer scientist Tim Berners-Lee to access the World
Wide Web (WWW). WWW makes it possible to consult web pages from

© Anthony Giretti 2023 1


A. Giretti, Coding Clean, Reliable, and Safe REST APIs with ASP.NET Core 8,
https://doi.org/10.1007/978-1-4842-9979-1_1
Chapter 1 Introducing HTTP and REST

a browser using HyperText Markup Language (HTML) through Uniform


Resource Identifier (URI) web addresses. At the beginning of HTTP’s
history, HTML was the language used to create pages, but since then,
HTTP has evolved into a web server that can process data formats other
than HTML. For example, a web server can serve (but also accept as input)
Extensible Markup Language (XML), which is a structured language, or
JavaScript Object Notation (JSON). Of course, a web server can serve other
types of data formats, categorized as Multipurpose Internet Mail Extensions
(MIME) type, and I will come back to this later.
HTTP follows a technical specification called Request From Comment
(RFC), developed by the Internet Engineering Task Force (IETF). There
are a ton of RFC specifications identified by numbers. The common point
among them is that they define the specifications of the Internet and only
the Internet. HTTP is defined by RFC 7231. RFC 7231 can be found at this
address: www.rfc-editor.org/rfc/rfc7231.

Note In this book, I will often refer to RFCs. The reason is that I
want to teach you the good practices for using HTTP. However, in
practice, the actual implementation of those RFCs may differ. Finally,
while this chapter aims to teach you the good techniques with HTTP,
I will not cover all the HTTP capabilities. I’ll stick to what you need to
know about building clean APIs with ASP.NET Core.

There are also different versions of HTTP. HTTP has evolved. I will not
go into details; in the following, you can find the published versions of the
protocol:

• HTTP/0.9 (obsolete)

• HTTP/1.0 (obsolete)

• HTTP/1.1 (still used)

2
Chapter 1 Introducing HTTP and REST

• HTTP/2 (in use but not widely used)

• HTTP/3 (new, not much used)

In this book, I will mainly refer to HTTP/1.1 and sometimes to HTTP/2


and HTTP/3 (when approaching the performance theme).

The Characteristics of HTTP


HTTP has three essential characteristics:

1. It is stateless: This means that after sending a


request to the server and receiving the response,
neither the client nor the server retains any
information on the exchanged request.

2. It is connectionless: An HTTP connection is open


between the client and the server. Once the client
has received the response from the server, the
connection is closed, and the connection between
the two systems is not permanent.

3. It is independent of the media, that is, the server


can transmit any media as long as the client and
the server “agree” on exchanging the content. (I will
return to this when I discuss headers.)

While HTTP is stateless, transmitting information between requests


may be necessary. Most web applications need to recognize the same
user during a browsing session (identify this user through browsing
between several web pages). To achieve this, an RFC describes HTTP
cookies designed to keep user data browser-side. I won’t go into this type
of “persistence” in this book, but I will employ more modern techniques.
However, if you are interested, consult RFC 6265 here: www.rfc-editor.
org/rfc/rfc6265.

3
Chapter 1 Introducing HTTP and REST

These characteristics may seem abstract, but they will become more
apparent as we read this book together. In the next section, I will give
you an overview of HTTP requests and responses. This will help you
understand HTTP before going into detail.

HTTP Requests and Responses


An HTTP connection works as follows: a request will receive a response
unless the connection is broken. Every request and every response works
the same way, and I’ll go into more detail in the next section.
An HTTP request works with elements as follows:

• A client (a browser, an application) initiates an HTTP


request by invoking a URI, the address of the requested
resource on the server.

• The URI requires the use of a verb that will determine


the action to be performed.

• Metadata will be sent in the HTTP request, called


headers. These headers allow controlling the
content negotiated with the server, such as sending
authentication information and much more.

• Parameters are necessary to exchange content with


the server and obtain the response sought, and the
parameters can be in the request’s body, the route, or
the URI.

An HTTP response works with elements as follows:

• The server returns a response with a simple status


code (HTTP status code) to determine how the HTTP
request processing took place.

4
Chapter 1 Introducing HTTP and REST

• The server also returns headers in response to the


client providing with different metadata.

• Finally, the server will return (or not) a payload


formatted in the MIME type requested by the client.

So far, I have briefly described and simplified how HTTP works.


Figure 1-1, therefore, summarizes what we have previously discussed.

Figure 1-1. A basic HTTP request and its response

In the following section, I will detail the HTTP verbs, the request
headers, the format of a URI, the different parameters passed in a
request, the HTTP status codes, the response headers, and the payload
formats returned to the client. Once we finish those points, I will bonify
Figure 1-1 with more details.

HTTP Implementation
Let’s dive into more detail to see what HTTP verbs, request headers,
response headers, and HTTP status codes are and how the client passes its
parameters in HTTP requests combined with the invocation of a URI.

5
Chapter 1 Introducing HTTP and REST

HTTP Verbs
RFC 7231 defines the following verbs:

• GET: This is the most well-known. It allows you to


request a resource from the server and receive a
response in the desired format (defined by the headers,
as we will see later in this chapter). The response is
cacheable (retain information in memory), and we will
discuss it in Chapter 6.

• HEAD: This verb is similar to the GET verb but does


not return any payload; a payload is used to request
metadata at the requested address. Since developers
barely use it most of the time, I won’t use it in this book,
but it’s good to know what it is used for. Like GET, the
server response is also cacheable.

• POST: This verb is interesting because it serves


multiple purposes. This verb allows the creation of new
resources, and its payload is attached to the request’s
body. (I will detail what’s a request body further in
this chapter.) Another way to send data is to use the
form-data technique, which will be described later in
this book. The POST verb also allows modifying data
by adding content to the data (appending data to the
resource representation according to the RFC). The
server response is not cacheable unless freshness
information is added to the response headers (max-­
age or Expires headers). We will discuss it again in the
“Request and Response Headers” section.

6
Chapter 1 Introducing HTTP and REST

• PUT: This verb is confusing because the RFC states


that it replaces a resource on the server. Very often,
developers confuse PUT and POST (replace a resource
vs. append data to a resource). The server response
here is not cacheable. However, if a resource doesn’t
exist, PUT should behave as POST by creating the
resource.

• DELETE: This verb is used to delete a resource. The


server response is not cacheable.

• CONNECT: The verb establishes a tunnel to the


server through a proxy (a server to which the HTTP
request will be delegated and access the server for
the requested request). This verb is used for secure
requests with Transport Layer Security (TLS), in other
words, HTTPS. I will also come back to HTTPS later in
this chapter. I never had to use this verb, and I won’t
talk about it in this book. The server response is not
cacheable.

• OPTIONS: This verb can be helpful when you want to


know what verbs are supported for a given URI. It’s also
used in the context of Cross-Origin Resource Sharing
(CORS), which has its dedicated section further in
this book. In the API world, you don’t necessarily
need to use this verb because you will usually know
the available URI for a given endpoint through the
OpenAPI specification. This will be discussed in the
“Extend Your Talent on the Web with REST Architecture
Style” section of this chapter. We will also see it together
in Chapter 4 when I bring up the API documentation
topic. The server response is not cacheable.

7
Chapter 1 Introducing HTTP and REST

• TRACE: A TRACE request sends a request to the


server with no particular payload. This lets you see if
intermediate servers, such as proxies, have altered the
original request. In the context of APIs, this verb is not
used. The server response is not cacheable.

RFC 7231 does not describe all the existing verbs, and there are others!
RFC 5789 defines the PATCH verb. This RFC can be found here: www.rfc-
editor.org/rfc/rfc5789.html.
The PATCH verb can be confused with PUT and POST verbs because
they all allow modifying a resource on a server. PATCH partially updates a
resource (like POST) when PUT tends to replace a resource.
I see many developers confusing each other. Now you are aware of
what the RFCs indicate about these verbs, but see that it is commonly
accepted to use POST for resource creation or to replace GET verb when
there are too many parameters in the URI to put them in the body of a
POST. It’s also commonly accepted to use PUT to entirely or partially
replace a resource even if PATCH is made for that. Personally, I rarely
use PATCH, only when I want to update a single property of a resource
(e.g., a date). From the moment I start modifying and altering several
properties of a resource (a date, a status, a description, etc.), I instead
implement PUT.
If you recall, I briefly mentioned HTTP status codes in this section. The
following section will discuss how status codes link to HTTP verbs. Some
verbs are used essentially with certain HTTP statuses. In the next section,
I will list the HTTP statuses and what verbs they can be associated with.

HTTP Status Codes


HTTP status codes are essential in an HTTP request/response between a
server and a client. They allow the client, when the server’s response has
been received, to be informed of the result of the processing by the server.
HTTP status codes are also governed by RFC 7231. I will not exhaustively

8
Chapter 1 Introducing HTTP and REST

detail each HTTP status class and each HTTP code because RFC 7231
does a pretty good job of doing so, and I won’t use all of them in this book.
Regarding APIs, status codes are essential for clients to understand what
the server is trying to tell us. They provide us with insights on what to
do next.
An HTTP status code has three digits. The first digit defines the status
category, and there are five categories of HTTP status codes:

• 1xx: They are purely informational.

• 2xx: They express that the server received and


processed the request successfully.

• 3xx: They inform the client that the server has


proceeded to a redirection, that is, the resource is not
at the address indicated, but that the request will be
redirected there automatically.

• 4xx: They mean the request (client-side) is malformed


and/or the client (the end user) probably made an
input error in their request. 4xx are errors that the client
can fix.

• 5xx: They tell the client that the request on the server
has not been completed due to an error.

RFC 7231 is not the only RFC that describes HTTP status codes.
However, it describes the codes most often used. RFC 4918 and RFC 6585
complete the list, with other codes covering other scenarios.
Table 1-1, taken from the following RFCs

• RFC 7231: www.rfc-editor.org/rfc/rfc7231

• RFC 4918: www.rfc-editor.org/rfc/rfc4918

• RFC 6585: www.rfc-editor.org/rfc/rfc6585

9
Chapter 1 Introducing HTTP and REST

lists the association between HTTP status codes and HTTP verbs
commonly used as industry standards. I won’t use all of them in this book;
you will not need to know them by heart. On the other hand, knowing their
existence is valuable since you will know their existence and how to use
them when required. Later in this book, I’ll dig deeper into why I’m using
some of them in the code samples I provide.

Table 1-1. List of available HTTP status codes and verbs most often
used with them
Code Reason phrase RFC Associated verb

100 Continue 7231 All verbs


101 Switching Protocols 7231 All verbs
200 OK 7231 GET, HEAD
201 Created 7231 POST
202 Accepted 7231 All verbs
203 Non-Authoritative Information 7231 GET
204 No Content 7231 POST, PUT, PATCH
205 Reset Content 7231 POST, PUT, PATCH
206 Partial Content 7231 GET
207 Multi-Status 4918 All verbs
300 Multiple Choices 7231 All verbs
301 Moved Permanently 7231 GET, HEAD, DELETE
302 Found 7231 GET, HEAD, DELETE
303 See Other 7231 GET, HEAD, DELETE
304 Not Modified 7231 GET, HEAD
(continued)

10
Chapter 1 Introducing HTTP and REST

Table 1-1. (continued)

Code Reason phrase RFC Associated verb

305 Use Proxy (deprecated) 7231 All verbs


307 Temporary Redirect 7231 All verbs
400 Bad Request 7231 POST, PUT, PATCH
401 Unauthorized 7231 All verbs
402 Payment Required 7231 Not used yet
403 Forbidden 7231 All verbs
404 Not Found 7231 All verbs except POST
405 Method Not Allowed 7231 All verbs
406 Not Acceptable 7231 All verbs
407 Proxy Authentication Required 7231 All verbs
408 Request Timeout 7231 All verbs
409 Conflict 7231 POST, PUT, PATCH
410 Gone 7231 All verbs except POST
411 Length Required 7231 POST, PUT, PATCH
412 Precondition Failed 4918 All verbs
413 Payload Too Large 7231 POST, PUT, PATCH
414 URI Too Long 7231 GET but applies to all verbs
415 Unsupported Media Type 7231 POST, PUT, PATCH
417 Expectation Failed 7231 All verbs
422 Unprocessable Entity 4918 POST, PUT, PATCH
423 Locked 4918 GET, HEAD, POST, PUT, PATCH
424 Failed Dependency 4918 All verbs
(continued)

11
Chapter 1 Introducing HTTP and REST

Table 1-1. (continued)

Code Reason phrase RFC Associated verb

426 Upgrade Required 4918 All verbs


500 Internal Error 7321 All verbs
501 Not Implemented 7231 All verbs
502 Bad Gateway 7231 All verbs
503 Service Unavailable 7231 All verbs
504 Gateway Timeout 7231 All verbs
505 HTTP Version Not Supported 7231 All verbs
507 Insufficient Storage 4918 POST, PUT, PATCH

This may seem like a lot of HTTP status codes, but remember that in
99% of the cases, you will only use a handful of codes described here.
Later in this book, we will come back together to some of them, and I
will explain them to you with examples of their usefulness.
Now let’s move on to another essential component of an HTTP request
and response, the request and response headers.

Request and Response Headers


HTTP headers are metadata that allows information to be passed between
the client and the server during a request/response flow. These headers
transport information but are not limited to authentication data and
information on the client’s browser.
In this section, I will differentiate between request headers and
response headers as they differ in nature for their purpose. For both the
request and response headers, RFC 7231 defines each (some are more
detailed, and some are defined in other RFCs, which RFC 7231 refers to).
As in my usual approach you’ve seen earlier, I will not go in depth since

12
Chapter 1 Introducing HTTP and REST

RFCs describe them in detail. Remember that this book will not cover
all possible use cases; specific headers are generated automatically by a
browser during the request, some during the response, and by the server.
You will not need to know them by heart. On the other hand, knowing they
exist is excellent as you get to know they exist and you can customize them
for your needs when necessary.

Note Although RFC 7231 describes (or redirects to other RFCs) the
best-known headers, in reality, there is a complete list of headers
(even the most unknown, but without many details) for which you can
consult RFC 4229 here: https://datatracker.ietf.org/doc/
html/rfc4229.

Request Headers
Like HTTP status codes, request headers are divided into classes, five
exactly:

• Controls headers

• Conditional headers

• Content Negotiation headers

• Authentication credentials headers

• Request context headers

In the following subsections, I will tell you in what RFCs these headers
are described, and I will list the links of these RFCs at the end of this
section.

13
Chapter 1 Introducing HTTP and REST

Controls Headers

There are seven headers in the Controls class. Some of them have various
possible directives (key/value pair):

• Cache-Control: Used to specify cache duration along


the request/response chain. They can handle several
directives, and their name perfectly describes their use.
For more details, I suggest you consult RFC 7234:

• no-cache: Doesn’t accept any value, works by itself

• no-store: Doesn’t accept any value, works by itself

• max-age: Accepts a value in seconds, for example,


Cache-Control: max-age=302400

• max-stale: Accepts a value in seconds, for example,


Cache-Control: max-stale=1800

• min-fresh: Accepts a value in seconds, for example,


Cache-Control: min-fresh=600

• no-transform: Doesn’t accept any value, works


by itself

• only-if-cached: Doesn’t accept any value, works


by itself

• Expect: Used to indicate expectations from the server


to process the request correctly, for example, Expect:
100-continue. For more details, I suggest you consult
RFC 7231.

• Host: Used to indicate the hostname (server) and the


port (optional) from the targeted URI, for example,
Host: www.example.com. For more details, I suggest you
consult RFC 7230.

14
Chapter 1 Introducing HTTP and REST

• Max-Forwards: Used to specify the limit of


intermediate servers (proxies) that forward the request.
Works only with TRACE and OPTIONS verbs and
accepts integer values. Example: Max-Forwards: 1. I
suggest you consult RFC 7231 for more details.

• Pragma: Used as backward compatibility with HTTP


1.0 cache. This header is ignored when the Cache-­
Control header is used. Example: Pragma: no-cache.
For more details, I suggest you consult RFC 7234.

• Range: Used to return a port of a document with a


given range of bytes (most often), for example, Range:
bytes 0-2048. For more details, I suggest you consult
RFC 7233.

• TE: Used to specify the chunk transfer coding, for


example, defining the compression algorithm, for
example, TE: gzip. For more details, I suggest you
consult RFC 7230.

Conditional Headers

Five conditional headers allow you to apply a condition on the target


resource for completing the request. Here they are:

• If-Match: Used to check if the requested resource


matches a current representation of the resource, for
example, If-Match: * (any resource) or If-Match: “123”,
which targets a resource with the ETag (Entity Tag)
“123”. ETag represents a specific version of a resource.
For more details, I suggest you consult RFC 7232.

15
Chapter 1 Introducing HTTP and REST

• If-None-Match: Used to check if the requested


resource does not match any current representation
of the resource. Works precisely the opposite of the
If-Match header. Example: If-None-Match: * (any
resource) or If-None-Match: “123,”. For more details, I
suggest you consult RFC 7232.

• If-Modified-Since: Used to check if the target resource


representation modification date is more recent than
the provided date, for example, If-Modified-Since: Wed,
22 Aug 2022 21:56:00 GMT. For more details, I suggest
you consult RFC 7232.

• If-Unmodified-Since: Used to check if the target


resource representation modification date is less recent
than the provided date, for example, If-Unmodified-­
Since: Wed, 22 Aug 2022 21:56:00 GMT. For more
details, I suggest you consult RFC 7232.

• If-Range: It’s a combination of If-Match and If-­


Modified-­Since headers, for example, If-Range: “123”
or If-Range: Wed, 22 Aug 2022 21:56:00 GMT. For more
details, I suggest you consult RFC 7233.

Content Negotiation Headers

Content Negotiation headers are essential in HTTP requests. They allow


the client and the server to understand each other on what format should
be exchanged. They are four in number:

• Accept: Used to define the MIME type that the client


can understand, for example, Accept: application/json
or Accept: application/json, application/xhtml+xml.
For more details, I suggest you consult RFC 7231.

16
Chapter 1 Introducing HTTP and REST

• Accept-Charset: Obsolete. Many browsers and servers


ignore this header. For more details, I suggest you
consult RFC 7231.

• Accept-Encoding: Used to define the compression


algorithm, for example, Accept-Encoding: deflate, gzip.
For more details, I suggest you consult RFC 7231.

• Accept-Language: Used to tell the server what


language the client is willing to accept, for example,
Accept-Language: * (all) or Accept-Language: en-­
CA. For more details, I suggest you consult RFC 7231.

Authentication Credentials Headers

Two authentication headers are necessary to interact with resources


protected by authentication. The first is particularly important because it
will be developed in this book. Here they are:

• Authorization: Used very often to authenticate


on the target server. It can handle different
types of authentication, such as bearer tokens
or basic authentication (both will be addressed
in Chapter 9). Example: Authorization: bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9…. For more
details, I suggest you consult RFC 7235.

• Proxy-Authorization: Same as Authorization, it is used


to authenticate proxies. Example: Proxy-Authorization:
basic YW50aG9ueWdpcmV0dGk6MTIzNA==. For more
details, I suggest you consult RFC 7235.

17
Exploring the Variety of Random
Documents with Different Content
that noble author himself alleged that he was engaged in ‘giving
fame to the Queen,’ the latter, one morning, noticed the alleged fact
to Lord Hervey. The King was present, and his Majesty remarked:—‘I
dare say he will paint you in fine colours, the dirty liar.’ ‘Why not?’
asked Caroline; ‘good things come out of dirt sometimes. I have ate
very good asparagus raised out of dung?’ When it was said that not
only Lord Carteret, but that Lords Bolingbroke and Chesterfield were
also engaged in writing the history of their times, the Queen
critically anticipated ‘that all the three histories would be three heaps
of lies; but lies of very different kinds: she said Bolingbroke’s would
be great lies; Chesterfield’s little lies; and Carteret’s lies of both
31
sorts.’ It may be added, that where there were vice and
coarseness there was little respect for justice or for independence of
conduct. The placeman who voted according to his conscience,
when he found his conscience in antagonism against the court, was
invariably removed from his place.
In concluding this chapter, it may be stated that when Frederick
was about to bring forward the question of his revenue, the Queen
would fain have had an interview with the son she alternately
despised and feared, to persuade him against pursuing this measure
—the carrying out of which she dreaded as prejudicial to the King’s
health in his present enfeebled state. Caroline, however, would not
see her son, for the reason, as the mother alleged, that he was such
an incorrigible liar that he was capable of making any mendacious
report of the interview, even of her designing to murder him. She
had, in an interview with him, at the time of the agitation connected
with the Excise bill, been compelled to place the Princess Caroline,
concealed, within hearing, that she might be a witness in case of the
prince, her brother, misrepresenting what had really taken place.
When the King learned the prince’s intentions, he took the
matter much more coolly than the Queen. Several messengers,
however, passed between the principal parties, but nothing was
done in the way of turning the prince from his purpose. It was an
innocent purpose enough, indeed, as he represented it. The
parliament had entrusted to the King a certain annual sum for the
prince’s use. The King and Queen did not so understand it, and he
simply applied to parliament to solicit that august body to put an
interpretation on its own act.
The supposed debilitated condition of the King’s health gave
increased hopes to the prince’s party. The Queen, therefore, induced
him to hold levées and appear more frequently in public. His
improvement in health and good humour was a matter of
disappointment to those who wished him dying, and feared to see
him grow popular.
The animosity of the Queen and her daughter, Caroline, against
32
the Prince of Wales was ferocious. The mother cursed the day on
which she had borne the son who was for ever destroying her
peace, and would end, she said, by destroying her life. There was no
opprobrious epithet which she did not cast at him; and they who
surrounded the Queen and princess had the honour of daily hearing
them hope that God would strike the son and brother dead with
apoplexy. Such enmity seems incredible. The gentle Princess
Caroline’s gentlest name for her brother was ‘that nauseous beast;’
and in running over the catalogue of crimes of which she declared
him capable, if not actually guilty, she did not hesitate to say that he
was capable of murdering even those whom he caressed. Never was
family circle so cursed by dissension as this royal circle; in which the
parents hated the son, the son the parents; the parents deceived
one another, the husband betrayed the wife, the wife deluded the
husband, the children were at mutual antagonism, and truth was a
stranger to all.
CHAPTER VII.
THE BIRTH OF AN HEIRESS.

Russian invasion of the Crimea—Announcement of an heir disbelieved by the


Queen—Princess of Wales conveyed to St. James’s by the Prince in a state
of labour—Birth of a Princess—Hampton Court Palace on this night—The
palace in an uproar—Indignation of Caroline—Reception of the Queen by
the Prince—Minute particulars afforded her by him—Explanatory notes
between the royal family—Message of the King—His severity to the Prince
—The Princess Amelia double-sided—Message of Princess Caroline to the
Prince—Unseemly conduct of the Prince—The Prince an agreeable
‘rattle’—The Queen’s anger never subsided—The Prince ejected from the
palace—The Queen and Lord Carteret—Reconciliation of the royal family
attempted—Popularity of the Prince—The Queen’s outspoken opinion of
the Prince—An interview between the King, Queen, and Lord Hervey—
Bishop Sherlock and the Queen—The King a purchaser of lottery-tickets.

The parliament, having passed a Land-tax bill of two shillings in the


pound, exempted the Prince of Wales from contributing even the
usual sixpence in the pound on his civil-list revenue, and settled a
dowry on his wife of 50,000l. per annum, peremptorily rejected Sir
John Bernard’s motion for decreasing the taxation which weighed
33
most heavily on the poor. The public found matter for much
speculation in these circumstances, and they alternately discussed
them with the subject of the aggressive ambition of Russia. The
latter power was then invading the Crimea with two armies under
Munich and Lasci. The occupier of the Muscovite throne stooped to
mendacity to veil the real object of the war; and there were Russian
officers not ashamed to be assassins—murdering the wounded foe
34
whom they found lying helpless on their path.
The interest in all home and foreign matters, however, was
speedily lost in that which the public took in the matter, which soon
presented itself, of the accession of an heir in the direct hereditary
line of Brunswick.
The prospect of the birth of a lineal heir to the throne ought to
have been one of general joy in a family whose own possession of
the crown was contested by the disinherited heir of the Stuart line.
The prospect, however, brought no joy with it on the present
occasion. It was not till within a month of the time for the event that
the Prince of Wales officially announced to his father, on the best
possible authority, the probability of the event itself. Caroline
appears at once to have disbelieved the announcement. She was so
desirous of the succession falling to her second son, William, that
she made no scruple of expressing her disbelief of what, to most
other observers, was apparent enough. She questioned the princess
herself, with more closeness than even the position of a mother-in-
law could justify; but for every query the well-trained Augusta had
one stereotyped reply—‘I don’t know.’ Caroline, on her side, resolved
to be better instructed. ‘I will positively be present,’ she exclaimed,
‘when the promised event takes place;’ adding, with her usual
broadness of illustration, ‘It can’t be got through as soon as one can
blow one’s nose; and I am resolved to be satisfied that the child is
hers.’
These suspicions, of which the Queen made no secret, were of
course well known to her son. He was offended by them; offended,
too, at a peremptory order that the birth of the expected heir should
take place in Hampton Court Palace; and he was, moreover, stirred
up by his political friends to exhibit his own independence, and to
oppose the royal wish, in order to show that he had a proper spirit
of freedom.
Accordingly, twice he brought the princess to London, and twice
returned with her to Hampton Court. Each time the journey had
been undertaken on symptoms of indisposition coming on, which,
however, passed away. At length one evening, the prince and
princess, after dining in public with the King and Queen, took leave
of them for the night, and withdrew to their apartments. Up to this
hour the princess had appeared to be in her ordinary health. Tokens
of supervening change came on, and the prince at once prepared for
action. The night (the 31st of July) was now considerably advanced,
and the Princess of Wales, who had been hitherto eager to obey her
husband’s wishes in all things, was now too ill to do anything but
pray against them. He would not listen to such petitions. He ordered
his ‘coach’ to be got ready and brought round to a side entrance of
the palace. The lights in the apartment were in the meantime
extinguished. He consigned his wife to the strong arms of
Desnoyers, the dancing-master, and Bloodworth, an attendant, who
dragged, rather than carried, her down stairs. In the meantime, the
poor lady, whose life was in very present peril, and sufferings
extreme, prayed earnestly to be permitted to remain where she was.
Subsequently she protested to the Queen that all that had been
done had taken place at her own express desire! However this may
be, the prince answered her prayers and moans by calling on her to
have courage; upbraiding her for her folly; and assuring her, with a
very manly complacency, that it was nothing, and would soon be
over! At length the coach was reached. It was the usually capacious
vehicle of the time, and into it got not only the prince and princess,
but Lady Archibald Hamilton and two female attendants. Vriad, who
was not only a valet-de-chambre, but a surgeon and accoucheur,
mounted the box. Bloodworth, the dancing-master, and two or three
more, got up behind. The prince enjoined the strictest silence on
such of his household as remained at Hampton Court, and therewith
the coach set off, at a gallop, not for the prince’s own residence at
Kew, but for St. James’s Palace, which was at twice the distance.
At the palace nothing was prepared for them. There was not a
couch ready for the exhausted lady, who had more than once on the
road been, as it seemed, upon the point of expiring; not even a bed
was ready for her to lie down and repose upon. No sheets were to
be found in the whole palace—or at least in that part over which the
prince had any authority. For lack of them, Frederick and Lady
Hamilton aired a couple of tablecloths, and these did the service
required of them.
In the meantime, notice had been sent to several officers of
state, and to the more necessary assistants required, to be present
at the imminent event. Most of the great officers were out of the
way. In lieu of them arrived the Lord President, Wilmington, and the
Lord Privy Seal, Godolphin. In their presence was born a daughter,
whom Lord Hervey designated as ‘a little rat’ and described as being
‘no bigger than a tooth-pick case.’
Perhaps it was the confusion which reigned before and at her
birth which had some influence on her intellects in after life. She was
an extremely pretty child, not without some mental qualifications;
but she became remarkable for making observations which inflicted
pain and embarrassment on those to whom they were addressed. In
after years, she also became the mother of that Caroline of
Brunswick who herself made confusion worse confounded in the
family into which she was received as a member—that Caroline
whom we recollect as the consort of George IV. and the protectress
of Baron Bergami.
At Hampton Court, the King and Queen, concluding that their
dear son and heir had, with his consort, relieved his illustrious
parents of his undesired presence for the night, thought of nothing
so little as of that son having taken it into his head to perform a trick
which might have been fittingly accompanied by the ‘Beggars’ Opera’
chorus of ‘Hurrah for the Road!’
No comedy has such a scene as that enacted at Hampton Court
on this night. While the prince was carrying off the princess, despite
all her agonising entreaties, the rest of the royal family were quietly
amusing themselves in another part of the palace, unconscious of
what was passing. The King and the Princess Amelia were at
commerce below-stairs; the Queen, in another apartment, was at
quadrille; and the Princess Caroline and Lord Hervey were soberly
playing at cribbage. They separated at ten, and were all in bed by
eleven, perfectly ignorant of what had been going on so near them.
At a little before two o’clock in the morning, Mrs. Tichborne
entered the royal bedchamber, when the Queen, waking in alarm,
asked her if the palace was on fire. The faithful servant intimated
that the prince had just sent word that her royal highness was on
the point of becoming a mother. A courier had just arrived, in fact,
with the intelligence. The Queen leaped out of bed and called for her
‘morning gown,’ wherein to hurry to the room of her daughter-in-
law. When Tichborne intimated that she would need a coach as well
as a gown, for that her royal highness had been carried off to St.
James’s, the Queen’s astonishment and indignation were equally
great. On the news being communicated to the King, his surprise
and wrath were not less than the Queen’s, but he did not fail to
blame his consort as well as his son. She had allowed herself to be
outwitted, he said; a false child would despoil her own offspring of
their rights; and this was the end of all her boasted care and
management for the interests of her son William! He hoped that
Anne would come from Holland and scold her. ‘You deserve,’ he
exclaimed, ‘anything she can say to you.’ The Queen answered little,
lest it should impede her in her haste to reach London. In half an
hour she had left the palace accompanied by her two daughters, and
attended by two ladies and three noblemen. The party reached St.
James’s by four o’clock.
As they ascended the staircase, Lord Hervey invited her Majesty
to take chocolate in his apartments after she had visited the
princess. The Queen replied to the invitation ‘with a wink,’ and a
significant intimation that she certainly would refuse to accept of any
refreshment at the hands of her son. One would almost suppose
that she expected to be poisoned by him.
The prince, attired, according to the hour, in nightgown and cap,
met his august mother as she approached his apartments, and
kissed her hand and cheek, according to the mode of his country
and times. He then entered garrulously into details that would have
shocked the delicacy of a monthly nurse; but, as Caroline remarked,
she knew a good many of them to be ‘lies.’ She was cold and
reserved to the prince; but when she approached the bedside of the
princess, she spoke to her gently and kindly—womanly, in short; and
concluded by expressing a fear that her royal highness had suffered
extremely, and a hope that she was doing well. The lady so
sympathisingly addressed, answered, somewhat flippantly, that she
had scarcely suffered anything, and that the matter in question was
almost nothing at all. Caroline transferred her sympathy from the
young mother to her new-born child. The latter was put into the
Queen’s arms. She looked upon it silently for a moment, and then
exclaimed in French, her ordinary language, ‘May the good God bless
you, poor little creature! here you are arrived in a most disagreeable
world.’ The wish failed, but the assertion was true. The ‘poor little
creature’ was cursed with a long tenure of life, during which she saw
her husband deprived of his inheritance, heard of his violent death,
and participated in family sorrow, heavy and undeserved.
After pitying the daughter thus born, and commiserating the
mother who bore her, Caroline was condemned to listen to the too
minute details of the journey and its incidents, made by her son. She
turned from these to shower her indignation upon those who had
aided in the flight, and without whose succour the flight itself could
hardly have been accomplished. She directed her indignation by
turns upon all; but she let it descend with peculiar heaviness upon
Lady Archibald Hamilton, and made it all the more pungent by the
comment, that, considering Lady Archibald’s mature age, and her
having been the mother of ten children, she had years enough, and
experience enough, and offspring enough, to have taught her better
things and greater wisdom. To all these winged words, the lady
attacked answered no further than by turning to the prince, and
repeating, ‘You see, sir!’ as though she would intimate that she had
done all she could to turn him from the evil of his ways, and had
gained only unmerited reproach for the exercise of a virtue, which,
in this case, was likely to be its own and its only reward!
The prince was again inclined to become gossiping and offensive
in his details, but his royal mother cut him short by bidding him get
to bed; and with this message by way of farewell, she left the room,
descended the staircase, crossed the court on foot, and proceeded
to Lord Hervey’s apartments, where there awaited her gossip more
welcome and very superior chocolate.
Over their ‘cups,’ right merry were the Queen and her gallant
vice-chamberlain at the extreme folly of the royal son. They were
too merry for Caroline to be indignant, further than her indignation
could be shown by designating her son by the very rudest possible
of names, and showing her contempt for all who had helped him in
the night’s escapade. She acknowledged her belief that no foul play
had taken place, chiefly because the child was a daughter. This
circumstance was in itself no proof of the genuineness of the little
lady, for if Frederick had been desirous of setting aside his brother
William, his mother’s favourite, from all hope of succeeding to the
throne, the birth of a daughter was quite as sufficient for the
35
purpose as that of a son. The Queen comforted herself by
remarking that, at all events, the trouble she had taken that night
was not gratuitous. It would at least, as she delicately remarked, be
a ‘good grimace for the public,’ who would contrast her parental
anxiety with the marital cruelty and the filial undutifulness of the
Prince of Wales.
While this genial pair were thus enjoying their chocolate and
gossip, the two princesses, and two or three of the noblemen in
attendance, were doing the same in an adjoining apartment.
Meanwhile Walpole had arrived, and had been closeted with the
prince, who again had the supreme felicity of narrating to the
unwilling listener all the incidents of the journey, in telling which he,
in fact, gave to the minister the opportunity which Gyges was
afforded by Candaules, or something very like it, and for which
Frederick merited, if not the fate of the heathen husband, at least
the next severe penalty short of it.
The sun was up long before the royal and illustrious party
dispersed. The busy children of industry, who saw the Queen and
her equipage sweep by them along the Western Road, must have
been perplexed with attempts at guessing at the causes of her
Majesty being so early abroad, in so wayworn a guise. The last thing
they could then have conjectured was the adventure of the night—
the scene at Hampton Court, the flight of the son with his wife, the
pursuit of the royal mother with her two daughters, the occurrence
at St. James’s—or, indeed, any of the incidents of the stirring drama
that had been played out.
From the hour when royalty had been suddenly aroused to that
at which the Queen arrived at Hampton Court Palace—eight in the
morning, George II. had troubled himself as little with conjecturing
as his subjects. When the Queen detailed to him all that had passed,
he poured out the usual amount of paternal wrath, and of the usual
quality. He never was nice of epithet, and least of all when he had
any to bestow upon his son. It was not spared now, and what was
most liberally given was most bitter of quality.
Meanwhile, both prince and princess addressed to their
Majesties explanatory notes in French, which explained nothing, and
which, as far as regards the prince’s notes, were in poor French and
worse spelling. Everything, of course, had been done for the best;
and the sole regret of the younger couple was, that they had
somehow, they could not guess how or wherefore, incurred the
displeasure of the King and Queen. To be restored to the good
opinion of the latter was, of course, the one object of the involuntary
offenders’ lives. In short, they had had their way; and, having
enjoyed that exquisite felicity, they were not reluctant to pretend
that they were extremely penitent for what had passed.
The displeasure of Caroline and her consort at the unfeeling
conduct of Frederick was made known to the latter neither in a
sudden nor an undignified way. It was not till the 10th of September
that it may be said to have been officially conveyed to the prince. On
that day the King and Queen sent a message to him from Hampton
Court, by the Dukes of Grafton and Richmond and the Earl of
Pembroke, who faithfully acquitted themselves of their unwelcome
commission at St. James’s. The message was to the effect, that ‘the
whole tenor of the prince’s conduct for a considerable time had been
so entirely void of all real duty, that their Majesties had long had
reason to be highly offended with him; and, until he withdrew his
regard and confidence from those by whose instigation and advice
he was directed and encouraged in his unwarrantable behaviour to
his Majesty and the Queen, and until he should return to his duty, he
should not reside in a palace belonging to the King, which his
Majesty would not suffer to be made the resort of those who, under
the appearance of an attachment to the prince, fomented the
divisions which he had made in his family, and thereby weakened
the common interest of the whole.’ Their Majesties further made
known their pleasure that ‘the prince should leave St. James’s, with
all his family, when it could be done without prejudice or
inconvenience to the princess.’ His Majesty added, that ‘he should,
for the present, leave the care of his grand-daughter until a proper
time called upon him to consider of her education.’ In consequence
of this message, the prince removed to Kew on the 14th of
September.
The King and Queen now not only treated their son with
extraordinary severity, and spoke of him in the coarsest possible
language, but they treated in like manner all who were suspected of
aiding and counselling him. Their wrath was especially directed
against Lord Carteret, who had at first deceived them. That noble
lord censured, in their hearing, a course of conduct in the prince
which he had himself suggested, and, in the hearing of the heir-
apparent, never failed to praise. When their Majesties discovered
this double-dealing, and that an attempt was being made to
convince the people that in the matter of the birth of the princess
royal, the Queen alone was to blame for all the disagreeable
incidents attending it, their anger was extreme. The feeling for Lord
Carteret was shown when Lord Hervey one day spoke of him with
some commiseration—his son having run away from school, and
there being no intelligence of him, except that he had formed a very
improper marriage. ‘Why do you pity him?’ said the King to Lord
Hervey: ‘I think it is a very just punishment, that, while he is acting
the villainous part he does in debauching the minds of other people’s
children, he should feel a little what it is to have an undutiful puppy
of a son himself!’
Fierce, indeed, was the family feud, and undignified as fierce.
The Princess Amelia is said to have taken as double-sided a line of
conduct as Lord Carteret himself; for which she incurred the ill-will of
both parties. The prince declared not only that he never would trust
her again, but that, should he ever be reconciled with the King and
Queen, his first care should be to inform them that she had never
said so much harm of him to them as she had of them to him. The
Princess Caroline was the more fierce partisan of the mother whom
she loved, from the fact that she saw how her brother was
endeavouring to direct the public feeling against the Queen. She
was, however, as little dignified in her fierceness as the rest of her
family. On one occasion, as Desnoyers, the dancing-master, had
concluded his lesson to the young princesses, and was about to
return to the prince, who made of him a constant companion, the
Princess Caroline bade him inform his patron, if the latter should
ever ask him what was thought of his conduct by her, that it was her
opinion that he and all who were with him, except the Princess of
Wales, deserved hanging. Desnoyers delivered the message, with
the assurances of respect given by one who acquits himself of a
disagreeable commission to one whom he regards. ‘How did the
prince take it?’ asked Caroline, when next Desnoyers appeared at
Hampton Court. ‘Well, madam,’ said the dancing-master, ‘he first
spat in the fire, and then observed, “Ah, ah! Desnoyers; you know
the way of that Caroline. That is just like her. She is always like
that!”’ ‘Well, M. Desnoyers,’ remarked the princess, ‘when next you
see him again, tell him that I think his observation is as foolish as his
conduct.’
The exception made by the Princess Caroline of the Princess of
Wales, in the censure distributed by the former, was not undeserved.
She was the mere tool of her husband, who made no confidante of
her, had not yet appreciated her, but kept her in the most complete
ignorance of all that was happening around her, and much of which
immediately concerned her. He used to speak of the office of wife in
the very coarsest terms; and did not scruple to declare that he
would not be such a fool as his father was, who allowed himself to
be ruled and deceived by his consort.
In the meantime, he treated his mother with mingled contempt
and hypocrisy. When, nine days after the birth of the little Princess
Augusta, the Queen and her two daughters again visited the
Princess of Wales, the prince, who met her at the door of the
bedchamber, never uttered a single word during the period his
mother remained in the room.
He was as silent to his sisters; but he was ‘the agreeable “rattle”’
with the members of the royal suite. The Queen remained an hour;
and when she remarked that she was afraid she was troublesome,
no word fell from the prince or princess to persuade her to the
contrary. When the royal carriage had arrived to conduct her away,
her son led her downstairs, and at the coach door, ‘to make the mob
believe that he was never wanting in any respect, he kneeled down
in the dirty street, and kissed her hand. As soon as this operation
was over, he put her Majesty into the coach, and then returned to
the steps of his own door, leaving his sisters to get through the dirt
and the mob, by themselves, as they could. Nor did there come to
the Queen any message, either from the prince or princess, to thank
her afterwards for the trouble she had taken, or for the honour she
had done them in this visit.’ This was the last time the mother and
son met in this world. Horace Walpole well observes of the scene
that it must have caused the Queen’s indignation to shrink into mere
contempt.
The Queen’s wrath never subsided beyond a cold expression of
forgiveness to the prince when she was on her death-bed; but she
resolutely refused to see him when that solemn hour arrived, a few
months subsequently. She was blamed for this; but her contempt
was too deeply rooted to allow her to act otherwise to one who had
done all he could to embitter the peace of his father. She sent to
him, it is said, her blessing and pardon; ‘but conceiving the extreme
distress it would lay on the King, should he thus be forced to forgive
so impenitent a son, or to banish him if once recalled, she heroically
36
preferred a meritorious husband to a worthless child.’
Had the prince been sincere in his expressions when addressing
either of his parents by letter after the delivery of his wife, it is not
impossible but that a reconciliation might have followed. His studied
disrespect towards the Queen was, however, too strongly marked to
allow of this conclusion to the quarrel. He invariably omitted to
speak of her as ‘your Majesty;’ Madam, and you, were the simple
and familiar terms employed by him. Indeed, he more than once told
her that he considered that the Prince of Wales took precedence of
the Queen-consort; at which Caroline would contemptuously laugh,
and assure her ‘dear Fritz’ that he need not press the point, for even
if she were to die, the King could not marry him!
It was for mere annoyance’ sake that he declared, at the end of
August, after the christening of his daughter, that she should not be
called the ‘Princess Augusta,’ but the ‘Lady Augusta,’ according to the
old English fashion. At the same time he declared that she should be
styled ‘Your Royal Highness,’ although such style had never been
used towards his own sisters before their father’s accession to the
crown.
It will hardly be thought necessary to go through the
documentary history of what passed between the Sovereigns and
their son before he was finally ejected from St. James’s Palace.
Wrong as he was in his quarrel, ‘Fritz’ kept a better temper, though
with as bitter a spirit as his parents. On the 13th of September, the
day before that fixed on for the prince’s departure, ‘the Queen, at
breakfast, every now and then repeated, I hope in God I shall never
see him again; and the King, among many other paternal douceurs
in his valediction to his son, said: Thank God! to-morrow night the
puppy will be out of my house.’ The Queen thought her son would
rather like, than otherwise, to be made a martyr of; but it was
represented to her, that however much it might have suited him to
be made one politically, there was more disgrace to him personally in
the present expulsion than he would like to digest. The King
maintained that his son had not sense of his own to find this out;
and that as he listened only to boobies, fools, and madmen, he was
not likely to have his case truly represented to him. And then the
King ran through the list of his son’s household; and Lord Carnarvon
was set down as being as coxcombical and irate a fool as his master;
Lord Townshend, for a proud, surly booby; Lord North, as a poor
creature; Lord Baltimore, as a trimmer; and ‘Johnny Lumley’ (the
brother of Lord Scarborough), as, if nothing else, at least ‘a
stuttering puppy.’ Such, it is said, were the followers of a prince, of
whom his royal mother remarked, that he was ‘a mean fool’ and ‘a
poor-spirited beast.’
While this dissension was at its hottest, the Queen fell ill of the
gout. She was so unwell, so weary of being in bed, and so desirous
of chatting with Lord Hervey, that she now for the first time broke
through the court etiquette, which would not admit a man, save the
Sovereign, into the royal bed-chamber. The noble lord was with her
there during the whole day of each day that her confinement lasted.
She was too old, she said, to have the honour of being talked of for
it; and so, to suit her humour, the old ceremony was dispensed with.
Lord Hervey sate by her bed-side, gossiped the live-long day; and on
one occasion, when the Prince of Wales sent Lord North with a
message of enquiry after her health, he amused the Queen by
turning the message into very slipshod verse, the point of which is at
once obscure and ill-natured, but which seems to imply that the
prince would have been well content had the gout, instead of being
in her foot, attacked her stomach.
The prince had been guilty of no such indecency as this; but
there was no lack of provocation to make him commit himself. When
he was turned out of St. James’s, he was not permitted to take with
him a single article of furniture. The royal excuse was, that the
furniture had been purchased, on the prince’s marriage, at the King’s
cost, and was his Majesty’s property. It was suggested that sheets
ought not to be considered as furniture; and that the prince and
princess could not be expected to carry away their dirty linen in
baskets. ‘Why not?’ asked the King; ‘it is good enough for them!’
Such were the petty circumstances with which Caroline and her
consort troubled themselves at the period in question. They at once
hurt their own dignity and made their son look ridiculous. The great
partisan of the latter (Lord Baltimore) did not rescue his master from
ridicule by comparing his conduct to that of the heroic Charles XII.
of Sweden. But the comparison was one to be expected from a man
whom the King had declared to be, in a great degree, a booby, and,
in a trifling degree, mad.
As soon as the prince had established himself at Kew, he was
waited on by Lord Carteret, Sir William Wyndham, and Mr. Pulteney.
The King could not conceal his anger under an affected contempt of
these persons or of their master. He endeavoured to satisfy himself
by abusing the latter, and by remarking that ‘they would soon be
tired of the puppy, who was, moreover, a scoundrel and a fool; and
who would talk more fiddle-faddle to them in a day than any old
woman talks in a week.’
The prince continued to address letters both to the King and
Queen, full of affected concern, expressed in rather impertinent
phrases. The princess addressed others, in which she sought to
justify her husband’s conduct; but as in all these notes there was a
studied disrespect of Caroline, the King would neither consent to
grant an audience to the offenders, nor would the Queen interfere to
induce him to relent.
The Queen, indeed, did not scruple to visit with her displeasure
all those courtiers who showed themselves inclined to bring about a
reconciliation; and yet she manifested some leaning towards Lord
Carteret, the chief agent of her son. This disposition alarmed
Walpole, who took upon himself to remind her that her minister
could serve her purpose better than her son’s, and that it was of the
utmost importance that she should conquer in this strife. ‘Is your son
to be bought?’ said Walpole. ‘If you will buy him, I will get him
cheaper than Carteret.’ Caroline answered only with ‘a flood of
grace, good words, favour, and professions’ of having full confidence
in her own minister—that is, Walpole himself—who had served her
so long and so faithfully.
A trait of Caroline’s character may here be mentioned, as
indicative of how she could help to build up her own reputation for
shrewdness by using the materials of others. Sir Robert Walpole, in
conversation with Lord Hervey, gave him some account of an
interview he had had with the Queen. The last-named gentleman
believed all the great minister had told him, because the Queen
herself had, in speaking of the subject to Lord Hervey, used the
precise terms now employed by Walpole. The subject was the
lukewarmness of some of the noblemen about court to serve the
King: the expression used was—‘People who keep hounds must not
hang every one that runs a little slower than the rest, provided, in
the main, they will go with the pack; one must not expect them all
to run just alike and to be equally good.’ Hervey told Walpole of the
use made by the Queen of this phrase, and Sir Robert naturally
enough remarked, ‘He was always glad when he heard she repeated
as her own any notion he had endeavoured to infuse, because it was
a sign what he had laboured had taken place.’
Meanwhile the prince was of himself doing little that could tend
to anything else than widen the breach already existing between him
and his family. He spoke aloud of what he would do when he came
to be King. His intentions, as reported by Caroline, were that she,
when she was Queen-dowager, should be ‘fleeced, flayed, and
minced.’ The Princess Amelia was to be kept in strict confinement;
the Princess Caroline left to starve; of the little princesses, Mary and
Louisa, then about fourteen and thirteen years of age, he made no
mention; and of his brother, the Duke of Cumberland, he always
spoke ‘with great affectation of kindness.’
Despite this imprudent conduct, endeavours continued to be
made by the prince and his friends, in order to bring about the
reconciliation which nobody seemed very sincere in desiring. The
Duke of Newcastle had implored the Princess Amelia, ‘For God’s
sake!’ to do her utmost ‘to persuade the Queen to make things up
with the prince before this affair was pushed to an extremity which
might make the wound incurable.’ The Queen is said to have been
exceedingly displeased with the Duke of Newcastle for thus
interfering in the matter. The Princess of Wales, however, continued
to write hurried and apparently earnest notes to the Queen,
thanking her for her kindness in standing godmother to her
daughter, treating her with ‘Your Majesty,’ and especially defending
her own husband, while affecting to deplore that his conduct,
misrepresented, had incurred the displeasure of their Majesties. ‘I
am deeply afflicted,’ so runs a note of the 17th of September, ‘at the
manner in which the prince’s conduct has been represented to your
Majesties, especially with regard to the two journeys which we made
from Hampton Court to London the week previous to my
confinement. I dare assure your Majesties, that the medical man and
midwife were then of opinion that I should not be confined before
the month of September, and that the indisposition of which I
complained was nothing more than the cholic. And besides, madam,
is it credible, that if I had gone twice to London with the design and
in the expectation of being confined there, I should have returned to
Hampton Court? I flatter myself that time and the good offices of
your Majesty will bring about a happy change in a situation of
affairs, the more deplorable for me inasmuch as I am the innocent
cause of it,’ &c.
This letter, delivered as the King and Queen were going to
chapel, was sent by the latter to Walpole, who repaired to the royal
closet in the chapel, where Caroline asked him what he thought of
this last performance? The answer was very much to the purpose.
Sir Robert said, he detected ‘you lie, you lie, you lie, from one end of
it to the other.’ Caroline agreed that the lie was flung at her by the
writer.
There was as much discussion touching the reply which should
be sent to this grievously offending note as if it had been a protocol
of the very first importance. One was for having it smart, another
formal, another so shaped that it should kindly treat the princess as
blameless, and put an end to further correspondence, with some
general wishes as to the future conduct of ‘Fritz.’ This was done, and
the letter was despatched. What effect it had upon the conduct of
the person alluded to may be discerned in the fact that when, on
Thursday, the 22nd of September, the prince and princess received
at Carlton House the Lord Mayor and Corporation of London, with an
address of congratulation on the birth of the Princess Augusta, the
lords of the prince’s present council distributed to everybody in the
room copies of the King’s message to the prince, ordering him to
quit St. James’s, and containing reflections against all persons who
might even visit the prince. The lords, particularly the Duke of
Marlborough and Lords Chesterfield and Carteret, deplored the
oppression under which the Prince of Wales struggled. His highness
also spoke to the citizens in terms calculated—certainly intended—to
win their favour.
He did not acquire all the popular favour he expected. Thus,
when, during the repairs of Carlton House, he occupied the
residence of the Duke of Norfolk, in St. James’s Square—a residence
which the duke and duchess refused to let to him, until they had
obtained the sanction of the King and Queen—‘he reduced the
number of his inferior servants, which made him many enemies
among the lower sort of people.’ He also diminished his stud, and
‘farmed all his tables, even that of the princess and himself.’ In other
words, his tables were supplied by a cook at so much per head.
His position was one, however, which was sure to procure for
him a degree of popularity, irrespective of his real merits. The latter,
however, were not great nor numerous, and even his own officers
considered their interests far before those of him they served—or
deserted. At the theatre, however, he was the popular hero of the
hour, and when once, on being present at the representation of
37
‘Cato,’ the words—

When vice prevails and impious men bear sway,


The post of honour is a private station—
were received with loud huzzas, the prince joined in the applause, to
show how he appreciated, and perhaps applied, the lines.
Although the King’s alleged oppression towards his son was
publicly canvassed by the latter, the prince and his followers
invariably named the Queen as the true author of it. The latter, in
commenting on this filial course, constantly sacrificed her dignity.
‘My dear lord,’ said Caroline, once, to Lord Hervey, ‘I will give it you
under my hand, if you have any fear of my relapsing, that my dear
first-born is the greatest ass, and the greatest liar, and the greatest
canaille, and the greatest beast, in the whole world, and that I most
heartily wish he was out of it!’ The King continued to treat him in
much the same strain, adding, courteously, that he had often asked
the Queen if the beast were his son. ‘The Queen was a great while,’
said he, ‘before her maternal affection would give him up for a fool,
and yet I told her so before he had been acting as if he had no
common sense.’ While so hard upon the conduct of their son, an
entry from Lord Hervey’s diary will show us what was their own: the
King’s with regard to decency, the Queen’s with respect to truth.
Whilst the Queen was talking one morning touching George I.’s
will and other family matters, with Lord Hervey, ‘the King opened her
door at the further end of the gallery; upon which the Queen chid
Lord Hervey for coming so late, saying, that she had several things
to say to him, and that he was always so long in coming, after he
was sent for, that she never had any time to talk with him. To which
Lord Hervey replied, that it was not his fault, for that he always
came the moment he was called; that he wished, with all his heart,
the King had more love, or Lady Deloraine more wit, that he might
have more time with her Majesty; but that he thought it very hard
that he should be snubbed and reproved because the King was old
and Lady Deloraine a fool. This made the Queen laugh; and the King
asking, when he came up to her, what it was at, she said it was at a
conversation Lord Hervey was reporting between the prince and Mr.
Lyttelton, on his being made secretary. The King desired him to
repeat it. Lord Hervey got out of the difficulty as he best could.
When the Queen and my lord next met, she said: “I think I was one
with you for your impertinence.” To which Lord Hervey replied, “The
next time you serve me so, madam, perhaps I may be even with
38
you, and desire your Majesty to repeat as well as report.”’
It may be noticed here, that both Frederick and the Queen’s
party published copies of the French correspondence which had
passed between the two branches of the family at feud, and that in
the translations appended to the letters, each party was equally
unscrupulous in giving such turns to the phrases as should serve
only one side, and injure the adverse faction. Bishop Sherlock, who
set the good fashion of residing much within his own diocese, once
ventured to give an opinion upon the prince’s conduct, which at least
served to show that the prelate was not a very finished courtier.
Bishops who reside within their dioceses, and trouble themselves
little with what takes place beyond it, seldom are. The bishop said
that the prince had lacked able counsellors, had weakly played his
game into the King’s hands, and made a blunder which he would
never retrieve. This remark provoked Caroline to say—‘I hope, my
lord, this is not the way you intend to speak your disapprobation of
my son’s measures anywhere else; for your saying that, by his
conduct lately, he has played his game into the King’s hands, one
would imagine you thought the game had been before in his own;
and though he has made his game still worse than it was, I am far
from thinking it ever was a good one, or that he had ever much
chance to win.’
Caroline, and indeed her consort also, conjectured that the
public voice and opinion were expressed in favour of the occupants
of the throne from the fact, that the birthday drawing-room of the
30th of October was the most splendid and crowded which had ever
been known since the King’s accession. That King himself probably
little cared whether he were popular or not. He was at this time
buying hundreds of lottery-tickets, out of the secret-service money,
and making presents of them to Madame Walmoden. A few fell,
perhaps, to the share of Lady Deloraine: ‘He’ll give her a couple of
tickets,’ said Walpole, ‘and think her generously used.’ His Majesty
would have rejoiced if he could have divided so easily his double
possession of England and Hanover. He had long entertained a wish
to give the Electorate to his second son, William of Cumberland, and
entertained a very erroneous idea that the English parliament could
assist him in altering the law of succession in the Electorate. Caroline
had, perhaps, not a much more correctly formed idea. She had a
conviction, however, touching her son, which was probably better
founded. ‘I knew,’ she said, ‘he would sell not only his reversion in
the Electorate, but even in this kingdom, if the Pretender would give
him five or six hundred thousand pounds in present; but, thank God!
he has neither right nor power to sell his family—though his folly and
39
his knavery may sometimes distress them.’
CHAPTER VIII.
DEATH OF CAROLINE.

Indisposition of the Queen—Her anxiety to conceal the cause—Walpole


closeted with her—Her illness assumes a grave character—Obliged to
retire from the Drawing-room—Affectionate attentions of Princess Caroline
—Continued bitter feeling towards the Prince—Discussions of the
physicians—Queen takes leave of the Duke of Cumberland—Parting scene
with the King—Interview with Walpole—The Prince denied the palace—
Great patience of the Queen—The Archbishop summoned to the palace—
Eulogy on the Queen pronounced by the King—His oddities—The Queen’s
exemplary conduct—Her death—Terror of Dr. Hulse—Singular conduct of
the King—Opposition to Sir R. Walpole—Lord Chesterfield pays court to
the Prince’s favourite.

After the birth of the Princess Louisa, on the 12th of December,


1724, Caroline, then Princess of Wales, was more than ordinarily
indisposed. Her indisposition was of such a nature that, though she
had made no allusion to it herself, her husband spoke to her on the
subject. The princess avoided entering upon a discussion, and
sought to satisfy the prince by remarking that her indisposition was
nothing more than what was common to her health, position, and
circumstances. For some years, although the symptoms were
neglected, the disease was not aggravated. At length more serious
indications were so perceptible to George, who was now King, that
he did not conceal his opinion that she was suffering from rupture.
This opinion she combated with great energy, for she had a rooted
aversion to its being supposed that she was afflicted with any
complaint. She feared lest the fact, being known, might lose her
some of her husband’s regard, or lead people to think that with
personal infirmity her power over him had been weakened. The King
again and again urged her to acknowledge that she suffered from
the complaint he had named, and to have medical advice on the
subject. Again and again she refused, and each time with renewed
expressions of displeasure; until at last, the King, contenting himself
with expressing a hope that she would not have to repent of her
obstinacy, made her a promise never to allude to the subject again
without her consent. The secret, however, was necessarily known to
others also; and we can only wonder that, being so known, more
active and effective measures were not taken to remedy an evil
which, in our days, at least, formidable as it may appear in name, is
so successfully treated as almost to deserve no more serious
appellation than a mere inconvenience.
Under an appearance of, at least, fair health, Queen Caroline
may be said to have been gradually decaying for years. Her pride
and her courage would not, however, allow of this being seen; and
when she rose, as was her custom, to curtsey to the King, not even
George himself was aware of the pain the effort cost her. Sir Robert
Walpole was long aware that she suffered greatly from some secret
malady, and it was not till after a long period of observation that he
succeeded in discovering her Majesty’s secret. He was often closeted
with her, arranging business that they were afterwards to nominally
transact in presence of the King, and to settle, as he imagined,
according to his will and pleasure. It was on some such occasion
that Sir Robert made the discovery in question. The minister’s wife
had just died; she was about the same age as Caroline, and the
Queen put to the minister such close, physical questions, and
adverted so frequently to the subject of rupture, of which Sir
Robert’s wife did not die, that the minister at once came to the
conclusion that her Majesty was herself suffering from that
40
complaint. This was the case: but the fact was only known to the
King himself, her German nurse (Mrs. Mailborne), and one other
person. A curious scene often occurred in her dressing-room and the
adjoining apartment. During the process of the morning toilette,
prayers were read in the outer room by her Majesty’s chaplain, the
latter kneeling the while beneath the painting of a nude Venus—
which, as Dr. Madox, a royal chaplain on service, once observed, was
a ‘very proper altar-piece.’ On these occasions, Walpole tells us that,
‘to prevent all suspicion, her Majesty would frequently stand some
minutes in her shift, talking to her ladies, and, though labouring with
so dangerous a complaint, she made it so invariable a rule never to
refuse a desire of the King, that every morning, at Richmond, she
walked several miles with him; and more than once, when she had
the gout in her foot, she dipped her whole leg in cold water to be
ready to attend him. The pain, her bulk, and the exercise, threw her
into such fits of perspiration as routed the gout; but those exertions
hastened the crisis of her distemper.’
In the summer of 1737 she suffered so seriously, that at length,
on the 26th of August, a report spread over the town that the Queen
41
was dead. The whole city at once assumed a guise of mourning—
gay summer or cheerful autumn dresses were withdrawn from the
shop windows, and nothing was to be seen in their place but ‘sables.’
The report, however, was unfounded. Her Majesty had been ill, but
one of her violent remedies had restored her for the moment. She
was thereby enabled to walk about Hampton Court with the King;
but she was not equal to the task of coming to London on the 29th
of the same month, when her grand-daughter Augusta was
christened, and King, Queen, and Duchess of Saxe Gotha stood
sponsors, by their proxies, to the future mother of a future Queen of
England.
At length, in November 1737, the crisis above alluded to
occurred, and Caroline’s illness soon assumed a very grave character.
Her danger, of which she was well aware, did not cause her to lose
her presence of mind, nor her dignity, nor to sacrifice any
characteristic of her disposition or reigning passion.
It was on Wednesday morning, the 9th of November, that the
Queen was seized with the illness which ultimately proved fatal to
her. She was distressed with violent internal pains, which Daffy’s
Elixir, administered to her by Dr. Tessier, could not allay. The violence
of the attack compelled her to return to bed early in the morning;
but her courage was great and the King’s pity small, and
consequently she rose, after resting for some hours, in order to
preside at the usual Wednesday’s drawing-room. The King had great
dislike to see her absent from this ceremony; without her, he used to
say, there was neither grace, gaiety, nor dignity; and, accordingly,
she went to this last duty with the spirit of a wounded knight who
returns to the field and dies in harness. She was not able long to
endure the fatigue. Lord Hervey was so struck by her appearance of
weakness and suffering, that he urged her, with friendly
peremptoriness, to retire from a scene for which she was evidently
unfitted. The Queen acknowledged her inability to continue any
longer in the room, but she could not well break up the assembly
without the King, who was in another part of the room, discussing
the mirth and merits of the last uproarious burlesque extravaganza,
‘The Dragon of Wantley.’ All London was then flocking to Covent
Garden to hear Lampe’s music and Carey’s light nonsense; and
Ryan’s Hamlet was not half so much cared for as Reinhold’s Dragon,
nor Mrs. Vincent’s Ophelia so much esteemed as the Margery and
Mauxalinda of the two Misses Young.
At length, his Majesty having been informed of the Queen’s
serious indisposition, and her desire to withdraw, took her by the
hand to lead her away, roughly noticing, at the same time, that she
had ‘passed over’ the Duchess of Norfolk. Caroline immediately
repaired her fault by addressing a few condescending words to that
old well-wisher of her family. They were the last words she ever
uttered on the public scene of her grandeur. All that followed was
the undressing after the great drama was over.
In the evening Lord Hervey again saw her. He had been dining
with the French ambassador, and he returned from the dinner at an
hour at which people now dress before they go to such a ceremony.
He was again at the palace by seven o’clock. His duty authorised
him, and his inclination prompted him, to see the Queen. He found
her suffering from increase of internal pains, violent sickness, and
progressive weakness. Cordials and various calming remedies were
prescribed, and while they were being prepared, a little
‘usquebaugh’ was administered to her; but neither whisky, nor
cordials, nor calming draughts could be retained. Her pains
increased, and therewith her strength diminished. She was
throughout this day and night affectionately attended by the
Princess Caroline, who was herself in extremely weak health, but
who would not leave her mother’s bedside till two o’clock in the
morning. The King then relieved her, after his fashion, which brought
relief to no one. He did not sit up to watch the sufferer, but, in his
morning gown, lay outside the bed, by the Queen’s side. Her
restlessness was very great, but the King did not leave her space
enough even to turn in bed; and he was so uncomfortable that he
was kept awake and ill-tempered throughout the night.
On the following day the Queen was bled, but without producing
any good effect. Her illness visibly increased, and George was as
visibly affected by it. Not so much so, however, as not to be
concerned about matters of dress. With the sight of the Queen’s
suffering before his eyes, he remembered that he had to meet the
foreign ministers that day, and he was exceedingly particular in
directing the pages to see that new ruffles were sewn to his old
shirt-sleeves, whereby he might wear a decent air in the eyes of the
representatives of foreign majesty. The Princess Caroline continued
to exhibit unabated sympathy for the mother who had perhaps loved
her better than any other of her daughters. The princess was in
tears and suffering throughout the day, and almost needed as much
care as the royal patient herself; especially after losing much blood
by the sudden breaking of one of the small vessels in the nose. It
was on this day that, to aid Broxholm, who had hitherto prescribed
for the Queen, Sir Hans Sloane and Dr. Hulse were called in. They
prescribed for an obstinate internal obstruction which could not be
overcome; and applied blisters to the legs—a remedy for which both
King and Queen had a sovereign and silly disgust.
On the 11th, the quiet of the palace was disturbed by a message
from the Prince of Wales, making enquiry after the condition of his
mother. His declared filial affection roused the King to a pitch of
almost ungovernable fury. The royal father flung at the son every
missile in his well-stored vocabulary of abuse. There really seemed
something devilish in this spirit at such a time. In truth, however, the
King had good ground for knowing that the assurances of the prince
were based upon the most patent hypocrisy. The spirit of the dying
Queen was nothing less fierce and bitter against the prince and his
adherents—that ‘Cartouche gang,’ as she was wont to designate
them. There was no touch of mercy in her, as regarded her feelings
or expressions towards him; and her epithets were not less
degrading to the utterer and to the object against whom they were
directed, than the King’s. She begged her husband to keep her son
from her presence. She had no faith, she said, in his assertions of
concern, respect, or sympathy. She knew he would approach her
with an assumption of grief; would listen dutifully, as it might seem,
to her laments; would ‘blubber like a calf’ at her condition; and
laugh at her outright as soon as he had left her presence.
It seems infinitely strange that it was not until the 12th of the
month that the King hinted to the Queen the propriety of her
physicians knowing that she was suffering from rupture. Caroline
listened to the suggestion with aversion and displeasure; she
earnestly entreated that what had hitherto been kept secret should
remain so. The King apparently acquiesced, but there is little doubt
of his having communicated a knowledge of the fact to Ranby, the
surgeon, who was now in attendance. When the Queen next
complained of violent internal pain, Ranby approached her, and she
directed his hand to the spot where she said she suffered most. Like
the skilful man that he was, Ranby contrived at the same moment to
satisfy himself as to the existence of the more serious complaint;
and having done so, went up to the King, and spoke to him in a
subdued tone of voice. The Queen immediately suspected what had
taken place, and, ill as she was, she railed at Ranby for a
‘blockhead.’ The surgeon, however, made no mystery of the matter;
but declared, on the contrary, that there was no time to be lost, and
that active treatment must at once be resorted to. The discovery of
the real malady which was threatening the Queen’s life, and which
would not have been perilous had it not been so strangely
neglected, cost Caroline the only tears she shed throughout her
trying illness.
Shipton and the able and octogenarian Bussier were now called
in to confer with the other medical men. It was at first proposed to
operate with the knife; but ultimately it was agreed that an attempt
should be made to reduce the tumour by less extreme means. The
Queen bore the necessary treatment patiently. Her chief watcher
and nurse was still the gentle Princess Caroline. The latter, however,
became so ill, that the medical men insisted on bleeding her. She
would not keep her room, but lay dressed on a couch in an
apartment next to that in which lay her dying mother. Lord Hervey,
when tired with watching—and his post was one of extreme fatigue
and anxiety—slept on a mattress, at the foot of the couch of the
Princess Caroline. The King retired to his own bed, and on this night
the Princess Amelia waited on her mother.
The following day, Sunday, the 13th, was a day of much
solemnity. The medical men announced that the wound from which
the Queen suffered had begun to mortify, and that death must
speedily supervene. The danger was made known to all; and of all,
Caroline exhibited the least concern. She took a solemn and
dignified leave of her children, always excepting the Prince of Wales.
Her parting with her favourite son, the young Duke of Cumberland,
was touching, and showed the depth of her love for him.
Considering her avowed partiality, there was some show of justice in
her concluding counsel to him that, should his brother Frederick ever
be King, he should never seek to mortify him, but simply try to
manifest a superiority over him only by good actions and merit. She
spoke kindly to her daughter Amelia, but much more than kindly to
the gentle Caroline, to whose care she consigned her two youngest
daughters, Louisa and Mary. She appears to have felt as little
inclination to see her daughter Anne, as she had to see her son
Frederick. Indeed, intimation had been given to the Prince of Orange
to the effect that not only was the company of the princess not
required, but that should she feel disposed to leave Holland for St.
James’s, he was to restrain her, by power of his marital authority.
The parting scene with the King was one of mingled dignity and
farce, touching incident and crapulousness. Caroline took from her
finger a ruby ring, and put it on a finger of the King. She tenderly
declared that whatever greatness or happiness had fallen to her
share, she had owed it all to him; adding, with something very like
profanity and general unseemliness, that naked she had come to
him and naked she would depart from him; for that all she had was
his, and she had so disposed of her own that he should be her heir.
The singular man to whom she thus addressed herself acted
singularly; and, for that matter, so also did his dying consort. Among
her last recommendations made on this day, was one enjoining him
to marry. The King, overcome, or seemingly overcome, at the idea of
being a widower, burst into a flood of tears. The Queen renewed her
injunctions that after her decease he should take a second wife. He
sobbed aloud; but amid his sobbing he suggested an opinion that he
thought that, rather than take another wife, he would maintain a
mistress or two. ‘Eh, mon Dieu!’ exclaimed Caroline, ‘the one does
not prevent the other! Cela n’empêche pas!’
A dying wife might have shown more decency, but she could
hardly have been more complaisant. Accordingly, when, after the
above dignified scene had been brought to a close, the Queen fell
into a profound sleep, George kissed her unconscious cheeks a
hundred times over, expressed an opinion that she would never
wake to recognition again, and gave evidence, by his words and
actions, how deeply he really regarded the dying woman before him.
It happened, however, that she did wake to consciousness again;
and then, with his usual inconsistency of temper, he snubbed as
much as he soothed her, yet without any deliberate intention of
being unkind. She expressed her conviction that she should survive
till the Wednesday. It was her peculiar day, she said. She had been
born on a Wednesday, was married on a Wednesday, first became a
mother on a Wednesday, was crowned on a Wednesday, and she
was convinced she should die on a Wednesday.
Her expressed indifference as to seeing Walpole is in strong
contrast with the serious way in which she did hold converse with

You might also like