Skip to content

Commit 6acca4c

Browse files
committed
corrected added headers
1 parent 4e3b4a1 commit 6acca4c

File tree

2 files changed

+21
-94
lines changed

2 files changed

+21
-94
lines changed

lib/utils/header_utils.dart

Lines changed: 15 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
21
Map<String, String> headers = {
3-
"Age": "It is a response header. It defines the times in seconds of the object that have been in the proxy cache.",
42
"Accept": "Specifies the media types that are acceptable for the response.",
5-
"Accept-charset":
6-
"It is a request type header. This header is used to indicate what character set are acceptable for the response from the server.",
73
"Accept-Encoding":
84
"Indicates the encoding methods the client can understand.",
5+
"Accept-Charset": "Specifies the character sets that are acceptable.",
96
"Access-Control-Allow-Headers":
107
"Specifies a list of HTTP headers that can be used in an actual request after a preflight request including the Access-Control-Request-Headers header is made.",
118
"Access-Control-Allow-Methods":
@@ -20,19 +17,11 @@ Map<String, String> headers = {
2017
"Used in preflight requests during CORS to indicate the HTTP method that will be used in the actual request.",
2118
"Accept-Language":
2219
"Specifies the preferred natural language and locale for the response.",
23-
"Accept-CH":
24-
"It is a response-type header. It specify which Client Hints headers client should include in subsequent requests.",
25-
"Accept-CH-Lifetime":
26-
"It is a response-type header used to specify persistence of Accept-CH header value.",
2720
"Authorization":
2821
"Contains credentials for authenticating the client with the server.",
2922
"Authorization Bearer Token": "Often used for token-based authentication.",
30-
"Alt-Svc":
31-
"It is use to reach the website in an alternate way.",
3223
"Cache-Control":
3324
"Provides directives for caching mechanisms in both requests and responses.",
34-
"Clear-Site-Data":
35-
"It is a response-type header. This header is used in deleting the browsing data which is in the requesting website.",
3625
"Connection":
3726
"Informs whether the connection stays open or close after the current transaction finishes.",
3827
"Content-Disposition":
@@ -42,7 +31,7 @@ Map<String, String> headers = {
4231
"Content-Length":
4332
"Indicates the size of the message body sent to the recipient in bytes.",
4433
"Content-Security-Policy":
45-
"Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.",
34+
"Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.",
4635
"Content-Type":
4736
"Indicates the original media type of the resource (prior to any content encoding applied for sending)",
4837
"Cookie": "Used to send previously stored cookies back to the server.",
@@ -52,21 +41,17 @@ Map<String, String> headers = {
5241
"Controls which documents are allowed to open a new window or access the current window.",
5342
"Cross-Origin-Resource-Policy":
5443
"Controls how cross-origin requests for resources are handled.",
55-
"Content-DPR":
56-
"It is a response-type header. It is used to define the ratio between physical pixels over CSS pixels of the selected image response.",
57-
"DPR": "It is response-type header, It is used to defines the ratio of the physical pixels over the CSS pixels of the current window of the device.",
58-
"Device-Memory":
59-
"It is used to specify the approximate ram left on the client device.",
6044
"Date": "Indicates the date and time at which the message was sent.",
45+
"Device-Memory":
46+
"Indicates the approximate amount of device memory in gigabytes.",
6147
"DNT":
6248
"Informs websites whether the user's preference is to opt out of online tracking.",
63-
"Early-Data":
64-
"It is a request-type header. This header is used indicate that the request has been conveyed in early data.",
65-
"ETag":
66-
"It is a response-type header used as an identifier for a specific version of a resource.",
6749
"Expect": "Indicates certain expectations that need to be met by the server.",
6850
"Expires":
6951
"Contains the date/time after which the response is considered expired",
52+
"Forwarded":
53+
"Contains information from the client-facing side of proxy servers that is altered or lost when a proxy is involved in the path of the request.",
54+
"From": "Contains an Internet email address for a human user who controls the requesting user agent.",
7055
"Host": "Specifies the domain name of the server and the port number.",
7156
"If-Match":
7257
"Used for conditional requests, allows the server to respond based on certain conditions.",
@@ -79,21 +64,14 @@ Map<String, String> headers = {
7964
"If-Unmodified-Since":
8065
"Used for conditional requests, allows the server to respond based on certain conditions.",
8166
"Keep-Alive":
82-
"It is a general-type header used to inform that how long a persistent connection should stay open.",
83-
"Last-Modified":
84-
"The last modified response header is a header sent by the server specifying the date of the last modification of the requested source. This is the formal definition of Last-Modified of HTTP headers.",
67+
"Used to allow the connection to be reused for further requests.",
8568
"Location":
8669
"Indicates the URL a client should redirect to for further interaction.",
87-
"Large-Allocation":
88-
"It is a response-type header that informs supported browsers (currently only Firefox) about the needs of a memory that allows them to make sure that the large-allocation succeeds and also start a new process using some unfragmented memory.",
89-
"Link":
90-
"It is entity-type header used to serializing one or more links in HTTP headers.",
70+
"Max-Forwards":
71+
"Indicates the remaining number of times a request can be forwarded by proxies.",
9172
"Origin": "Specifies the origin of a cross-origin request.",
92-
"Proxy-Authenticate": "It is a response header gives access to a resource file by defining an authorization method. It allows the proxy server to transmit the request further by authenticating it.",
9373
"Proxy-Authorization":
94-
"It is a request type of header. This header contains the credentials to authenticate between the user agent and the user-specified server.",
95-
"Pragma":
96-
"It is general-type header, but response behavior is not specified and thus implementation-specific.",
74+
"Contains credentials for authenticating a client with a proxy server.",
9775
"Range":
9876
"Used to request only part of a resource, typically in the context of downloading large files.",
9977
"Referer":
@@ -103,33 +81,17 @@ Map<String, String> headers = {
10381
"Retry-After":
10482
"Informs the client how long it should wait before making another request after a server has responded with a rate-limiting status code.",
10583
"Save-Data":
106-
"It is used to reduce the usage of the data on the client side.",
84+
"Indicates the client's preference for reduced data usage.",
10785
"Server": "Indicates the software used by the origin server.",
108-
"Server-Timing":
109-
"It is a response-type header. This header is used to communicate between two or more metrics and descriptions for a given request-response cycle from the user agent.",
110-
"SourceMap":
111-
"It is a response-type header used to map original source from the transformed source. For example, the JavaScript resources are transformed to some other source from its original by the browsers at the time of execution.",
11286
"Strict-Transport-Security":
11387
"Instructs the browser to always use HTTPS for the given domain.",
114-
"Timing-Allow-Origin":
115-
"It is a response type header. It specify origins that are allowed to see values of attributes retrieved via features of the Resource Timing API.",
116-
"TK":
117-
"It is a response type header, it indicates the tracking status.",
11888
"TE": "Specifies the transfer encodings that are acceptable to the client.",
89+
"Upgrade-Insecure-Requests":
90+
"Instructs the browser to prefer secure connections when available.",
11991
"User-Agent":
12092
"Identifies the client software and version making the request.",
121-
"Vary":
122-
"It is response-type header. It is used by the server to indicate which headers it used when selecting a representation of a resource in a content negotiation algorithm.",
12393
"Via":
12494
"Indicates intermediate proxies or gateways through which the request or response has passed.",
125-
"Viewport-Width":
126-
"It is used to indicates the layout viewport width in CSS pixels.",
127-
"Width":
128-
"It is a request-type header. This header is used indicates the desired resource width in physical pixels.",
129-
"Warnings":
130-
"It is a general type header that is used to inform possible problems to the client.",
131-
"WWW-Authenticate":
132-
"It is a response header that defines the authentication method. It should be used to gain access to a resource.",
13395
"X-Api-Key": "Used to authenticate requests to an API with an API key.",
13496
"X-Content-Type-Options":
13597
"Used to prevent browsers from MIME-sniffing a response.",
@@ -143,8 +105,6 @@ Map<String, String> headers = {
143105
"Indicates whether the request was made with JavaScript using XMLHttpRequest.",
144106
"X-XSS-Protection":
145107
"Enables or disables the browser's built-in cross-site scripting (XSS) filter.",
146-
"X-DNS-Prefetch-Control":
147-
"It is response-type header that is used to control the DNS prefetch."
148108
};
149109

150110
List<String> getHeaderSuggestions(String pattern) {
@@ -153,4 +113,4 @@ List<String> getHeaderSuggestions(String pattern) {
153113
(element) => element.toLowerCase().contains(pattern.toLowerCase()),
154114
)
155115
.toList();
156-
}
116+
}

test/utils/header_utils_test.dart

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,6 @@
11
import 'package:apidash/utils/header_utils.dart';
22
import 'package:test/test.dart';
33

4-
// new headers
5-
// X-DNS-Proxy-Authenticate
6-
// Proxy-Authorization
7-
// WWW-Authenticate
8-
// Age
9-
// Clear-Site-Data
10-
// Pragma
11-
// Warnings
12-
// Accept-CH
13-
// Accept-CH-Lifetime
14-
// Content-DPR
15-
// DPR
16-
// Device-Memory
17-
// Early-Data
18-
// Save-Data
19-
// Viewport-Width
20-
// Width
21-
// Last-Modified
22-
// ETag
23-
// Vary
24-
// Keep-Alive
25-
// Accept-charset
26-
// Timing-Allow-Origin
27-
// TK
28-
// Alt-Svc
29-
// Large-Allocation
30-
// Link
31-
// Server-Timing
32-
// SourceMap
33-
// X-DNS-Prefetch-Control
344
void main() {
355
group("Testing getHeaderSuggestions function", () {
366
test("Testing using Allow-Headers", () {
@@ -47,7 +17,7 @@ void main() {
4717

4818
test("Testing using Allow-Origin", () {
4919
String pattern = "Allow-Origin";
50-
List<String> expected = ["Access-Control-Allow-Origin", "Timing-Allow-Origin"];
20+
List<String> expected = ["Access-Control-Allow-Origin"];
5121
expect(getHeaderSuggestions(pattern), expected);
5222
});
5323

@@ -123,8 +93,7 @@ void main() {
12393
List<String> expected = [
12494
"Access-Control-Allow-Headers",
12595
"Access-Control-Allow-Methods",
126-
"Access-Control-Allow-Origin",
127-
"Timing-Allow-Origin"
96+
"Access-Control-Allow-Origin"
12897
];
12998
expect(getHeaderSuggestions(pattern), expected);
13099
});
@@ -137,7 +106,6 @@ void main() {
137106
'Content-Length',
138107
'Content-Security-Policy',
139108
'Content-Type',
140-
"Content-DPR",
141109
'X-Content-Type-Options'
142110
];
143111
expect(getHeaderSuggestions(pattern), expected);
@@ -147,14 +115,14 @@ void main() {
147115
String pattern = "x-";
148116
List<String> expected = [
149117
"Access-Control-Max-Age",
118+
"Max-Forwards",
150119
"X-Api-Key",
151120
"X-Content-Type-Options",
152121
"X-CSRF-Token",
153122
"X-Forwarded-For",
154123
"X-Frame-Options",
155124
"X-Requested-With",
156-
"X-XSS-Protection",
157-
"X-DNS-Prefetch-Control",
125+
"X-XSS-Protection"
158126
];
159127
expect(getHeaderSuggestions(pattern), expected);
160128
});
@@ -166,10 +134,9 @@ void main() {
166134
'Cross-Origin-Embedder-Policy',
167135
'Cross-Origin-Opener-Policy',
168136
'Cross-Origin-Resource-Policy',
169-
'Origin',
170-
'Timing-Allow-Origin'
137+
'Origin'
171138
];
172139
expect(getHeaderSuggestions(pattern), expected);
173140
});
174141
});
175-
}
142+
}

0 commit comments

Comments
 (0)