diff --git a/lib/consts.dart b/lib/consts.dart index 51915ef0..ad5a4129 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -543,6 +543,115 @@ const kResponseCodeReasons = { 511: 'Network Authentication Required', }; +Map kHttpHeadersMap = { + "Accept": "Specifies the media types that are acceptable for the response.", + "Accept-Encoding": + "Indicates the encoding methods the client can understand.", + "Accept-Charset": "Specifies the character sets that are acceptable.", + "Access-Control-Allow-Headers": + "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.", + "Access-Control-Allow-Methods": + "Specifies a list of HTTP request methods allowed during CORS. ", + "Access-Control-Allow-Origin": + "Indicates whether the response can be shared with the requesting code from the given origin.", + "Access-Control-Max-Age": + "Indicates the maximum amount of time the results of a preflight request can be cached.", + "Access-Control-Request-Headers": + "Used in preflight requests during CORS to specify the headers that will be included in the actual request.", + "Access-Control-Request-Method": + "Used in preflight requests during CORS to indicate the HTTP method that will be used in the actual request.", + "Accept-Language": + "Specifies the preferred natural language and locale for the response.", + "Authorization": + "Contains credentials for authenticating the client with the server.", + "Authorization Bearer Token": "Often used for token-based authentication.", + "Cache-Control": + "Provides directives for caching mechanisms in both requests and responses.", + "Connection": + "Informs whether the connection stays open or close after the current transaction finishes.", + "Content-Disposition": + "Specifies the presentation style (inline or attachment) of the response.", + "Content-Encoding": + "Indicates the encoding transformations that have been applied to the entity body of the response.", + "Content-Length": + "Indicates the size of the message body sent to the recipient in bytes.", + "Content-Security-Policy": + "Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.", + "Content-Type": + "Indicates the original media type of the resource (prior to any content encoding applied for sending)", + "Cookie": "Used to send previously stored cookies back to the server.", + "Cross-Origin-Embedder-Policy": + "Controls whether a document is allowed to be embedded in another document.", + "Cross-Origin-Opener-Policy": + "Controls which documents are allowed to open a new window or access the current window.", + "Cross-Origin-Resource-Policy": + "Controls how cross-origin requests for resources are handled.", + "Date": "Indicates the date and time at which the message was sent.", + "Device-Memory": + "Indicates the approximate amount of device memory in gigabytes.", + "DNT": + "Informs websites whether the user's preference is to opt out of online tracking.", + "Expect": "Indicates certain expectations that need to be met by the server.", + "Expires": + "Contains the date/time after which the response is considered expired", + "Forwarded": + "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.", + "From": + "Contains an Internet email address for a human user who controls the requesting user agent.", + "Host": "Specifies the domain name of the server and the port number.", + "If-Match": + "Used for conditional requests, allows the server to respond based on certain conditions.", + "If-Modified-Since": + "Used for conditional requests, allows the server to respond based on certain conditions.", + "If-None-Match": + "Used for conditional requests, allows the server to respond based on certain conditions.", + "If-Range": + "Used in conjunction with the Range header to conditionally request a partial resource.", + "If-Unmodified-Since": + "Used for conditional requests, allows the server to respond based on certain conditions.", + "Keep-Alive": + "Used to allow the connection to be reused for further requests.", + "Location": + "Indicates the URL a client should redirect to for further interaction.", + "Max-Forwards": + "Indicates the remaining number of times a request can be forwarded by proxies.", + "Origin": "Specifies the origin of a cross-origin request.", + "Proxy-Authorization": + "Contains credentials for authenticating a client with a proxy server.", + "Range": + "Used to request only part of a resource, typically in the context of downloading large files.", + "Referer": + "Indicates the URL of the page that referred the client to the current URL.", + "Referrer-Policy": + "Specifies how much information the browser should include in the Referer header when navigating to other pages.", + "Retry-After": + "Informs the client how long it should wait before making another request after a server has responded with a rate-limiting status code.", + "Save-Data": "Indicates the client's preference for reduced data usage.", + "Server": "Indicates the software used by the origin server.", + "Strict-Transport-Security": + "Instructs the browser to always use HTTPS for the given domain.", + "TE": "Specifies the transfer encodings that are acceptable to the client.", + "Upgrade-Insecure-Requests": + "Instructs the browser to prefer secure connections when available.", + "User-Agent": + "Identifies the client software and version making the request.", + "Via": + "Indicates intermediate proxies or gateways through which the request or response has passed.", + "X-Api-Key": "Used to authenticate requests to an API with an API key.", + "X-Content-Type-Options": + "Used to prevent browsers from MIME-sniffing a response.", + "X-CSRF-Token": + "Used for protection against Cross-Site Request Forgery (CSRF) attacks.", + "X-Forwarded-For": + "Identifies the client's original IP address when behind a proxy or load balancer.", + "X-Frame-Options": + "Controls whether a webpage can be displayed within an iframe or other embedded frame elements.", + "X-Requested-With": + "Indicates whether the request was made with JavaScript using XMLHttpRequest.", + "X-XSS-Protection": + "Enables or disables the browser's built-in cross-site scripting (XSS) filter.", +}; + const kMimeTypeRaiseIssue = "{% if showRaw %}Please click on 'Raw' to view the unformatted raw results as we{% else %}We{% endif %} encountered an error rendering this {% if showContentType %}Content-Type {% endif %}{{type}}.\nPlease raise an issue in API Dash GitHub repo so that we can look into this issue."; diff --git a/lib/utils/header_utils.dart b/lib/utils/header_utils.dart index 1450cc01..07c09e75 100644 --- a/lib/utils/header_utils.dart +++ b/lib/utils/header_utils.dart @@ -1,114 +1,7 @@ -Map headers = { - "Accept": "Specifies the media types that are acceptable for the response.", - "Accept-Encoding": - "Indicates the encoding methods the client can understand.", - "Accept-Charset": "Specifies the character sets that are acceptable.", - "Access-Control-Allow-Headers": - "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.", - "Access-Control-Allow-Methods": - "Specifies a list of HTTP request methods allowed during CORS. ", - "Access-Control-Allow-Origin": - "Indicates whether the response can be shared with the requesting code from the given origin.", - "Access-Control-Max-Age": - "Indicates the maximum amount of time the results of a preflight request can be cached.", - "Access-Control-Request-Headers": - "Used in preflight requests during CORS to specify the headers that will be included in the actual request.", - "Access-Control-Request-Method": - "Used in preflight requests during CORS to indicate the HTTP method that will be used in the actual request.", - "Accept-Language": - "Specifies the preferred natural language and locale for the response.", - "Authorization": - "Contains credentials for authenticating the client with the server.", - "Authorization Bearer Token": "Often used for token-based authentication.", - "Cache-Control": - "Provides directives for caching mechanisms in both requests and responses.", - "Connection": - "Informs whether the connection stays open or close after the current transaction finishes.", - "Content-Disposition": - "Specifies the presentation style (inline or attachment) of the response.", - "Content-Encoding": - "Indicates the encoding transformations that have been applied to the entity body of the response.", - "Content-Length": - "Indicates the size of the message body sent to the recipient in bytes.", - "Content-Security-Policy": - "Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.", - "Content-Type": - "Indicates the original media type of the resource (prior to any content encoding applied for sending)", - "Cookie": "Used to send previously stored cookies back to the server.", - "Cross-Origin-Embedder-Policy": - "Controls whether a document is allowed to be embedded in another document.", - "Cross-Origin-Opener-Policy": - "Controls which documents are allowed to open a new window or access the current window.", - "Cross-Origin-Resource-Policy": - "Controls how cross-origin requests for resources are handled.", - "Date": "Indicates the date and time at which the message was sent.", - "Device-Memory": - "Indicates the approximate amount of device memory in gigabytes.", - "DNT": - "Informs websites whether the user's preference is to opt out of online tracking.", - "Expect": "Indicates certain expectations that need to be met by the server.", - "Expires": - "Contains the date/time after which the response is considered expired", - "Forwarded": - "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.", - "From": "Contains an Internet email address for a human user who controls the requesting user agent.", - "Host": "Specifies the domain name of the server and the port number.", - "If-Match": - "Used for conditional requests, allows the server to respond based on certain conditions.", - "If-Modified-Since": - "Used for conditional requests, allows the server to respond based on certain conditions.", - "If-None-Match": - "Used for conditional requests, allows the server to respond based on certain conditions.", - "If-Range": - "Used in conjunction with the Range header to conditionally request a partial resource.", - "If-Unmodified-Since": - "Used for conditional requests, allows the server to respond based on certain conditions.", - "Keep-Alive": - "Used to allow the connection to be reused for further requests.", - "Location": - "Indicates the URL a client should redirect to for further interaction.", - "Max-Forwards": - "Indicates the remaining number of times a request can be forwarded by proxies.", - "Origin": "Specifies the origin of a cross-origin request.", - "Proxy-Authorization": - "Contains credentials for authenticating a client with a proxy server.", - "Range": - "Used to request only part of a resource, typically in the context of downloading large files.", - "Referer": - "Indicates the URL of the page that referred the client to the current URL.", - "Referrer-Policy": - "Specifies how much information the browser should include in the Referer header when navigating to other pages.", - "Retry-After": - "Informs the client how long it should wait before making another request after a server has responded with a rate-limiting status code.", - "Save-Data": - "Indicates the client's preference for reduced data usage.", - "Server": "Indicates the software used by the origin server.", - "Strict-Transport-Security": - "Instructs the browser to always use HTTPS for the given domain.", - "TE": "Specifies the transfer encodings that are acceptable to the client.", - "Upgrade-Insecure-Requests": - "Instructs the browser to prefer secure connections when available.", - "User-Agent": - "Identifies the client software and version making the request.", - "Via": - "Indicates intermediate proxies or gateways through which the request or response has passed.", - "X-Api-Key": "Used to authenticate requests to an API with an API key.", - "X-Content-Type-Options": - "Used to prevent browsers from MIME-sniffing a response.", - "X-CSRF-Token": - "Used for protection against Cross-Site Request Forgery (CSRF) attacks.", - "X-Forwarded-For": - "Identifies the client's original IP address when behind a proxy or load balancer.", - "X-Frame-Options": - "Controls whether a webpage can be displayed within an iframe or other embedded frame elements.", - "X-Requested-With": - "Indicates whether the request was made with JavaScript using XMLHttpRequest.", - "X-XSS-Protection": - "Enables or disables the browser's built-in cross-site scripting (XSS) filter.", -}; +import '../consts.dart'; List getHeaderSuggestions(String pattern) { - return headers.keys + return kHttpHeadersMap.keys .where( (element) => element.toLowerCase().contains(pattern.toLowerCase()), ) diff --git a/lib/widgets/response_widgets.dart b/lib/widgets/response_widgets.dart index 954ac60b..134aedc2 100644 --- a/lib/widgets/response_widgets.dart +++ b/lib/widgets/response_widgets.dart @@ -324,7 +324,8 @@ class ResponseBody extends StatelessWidget { Widget build(BuildContext context) { final responseModel = selectedRequestModel?.httpResponseModel; if (responseModel == null) { - return const ErrorMessage(message: '$kNullResponseModelError $kUnexpectedRaiseIssue'); + return const ErrorMessage( + message: '$kNullResponseModelError $kUnexpectedRaiseIssue'); } var body = responseModel.body;