@h3ravel/http 11.7.7 → 11.8.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BLWcukCW.js → chunk-Zh1HL_PD.js} +13 -13
- package/dist/{chunk-BncF-t-1.cjs → chunk-xvyjDJxY.cjs} +16 -16
- package/dist/env.d.ts +1 -0
- package/dist/{find-up-simple-C7LasaJE.cjs → find-up-simple-BT_3Z5Fk.cjs} +3 -3
- package/dist/{find-up-simple-Cb60ihyu.js → find-up-simple-D3xUobXL.js} +3 -3
- package/dist/index.cjs +3577 -2808
- package/dist/index.d.ts +598 -236
- package/dist/index.js +3438 -2670
- package/package.json +9 -8
- package/dist/app.globals.d.ts +0 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
2
|
import { Command } from "@h3ravel/musket";
|
|
3
|
+
import * as _h3ravel_contracts0 from "@h3ravel/contracts";
|
|
4
|
+
import { CacheOptions, ClassConstructor, DotNestedKeys, DotNestedValue, GenericObject, IApplication, IHeaderBag, IHttpContext, IHttpResponse, IMiddleware, IParamBag, IRequest, IResponsable, IResponse, IRoute, ISessionManager, IUrl, MessagesForRules, RequestMethod, RequestObject, ResponseObject, RulesForData } from "@h3ravel/contracts";
|
|
3
5
|
import { DateTime } from "@h3ravel/support";
|
|
4
6
|
import { EventHandlerRequest, H3Event, HTTPResponse } from "h3";
|
|
5
|
-
import {
|
|
6
|
-
import { Application } from "@h3ravel/core";
|
|
7
|
-
import { Url } from "@h3ravel/url";
|
|
7
|
+
import { ResponseCodes } from "@h3ravel/foundation";
|
|
8
8
|
|
|
9
9
|
//#region src/Commands/FireCommand.d.ts
|
|
10
10
|
declare class FireCommand extends Command {
|
|
@@ -24,24 +24,6 @@ declare class FireCommand extends Command {
|
|
|
24
24
|
protected fire(): Promise<void>;
|
|
25
25
|
}
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region src/Contracts/HttpContract.d.ts
|
|
28
|
-
type CacheOptions = Partial<{
|
|
29
|
-
must_revalidate: boolean;
|
|
30
|
-
no_cache: boolean;
|
|
31
|
-
no_store: boolean;
|
|
32
|
-
no_transform: boolean;
|
|
33
|
-
public: boolean;
|
|
34
|
-
private: boolean;
|
|
35
|
-
proxy_revalidate: boolean;
|
|
36
|
-
max_age: number;
|
|
37
|
-
s_maxage: number;
|
|
38
|
-
immutable: boolean;
|
|
39
|
-
stale_while_revalidate: number;
|
|
40
|
-
stale_if_error: number;
|
|
41
|
-
last_modified: string | Date;
|
|
42
|
-
etag: string;
|
|
43
|
-
}>;
|
|
44
|
-
//#endregion
|
|
45
27
|
//#region src/Exceptions/BadRequestException.d.ts
|
|
46
28
|
declare class BadRequestException extends Error {
|
|
47
29
|
constructor(message: string);
|
|
@@ -55,9 +37,9 @@ declare class ConflictingHeadersException extends Error {
|
|
|
55
37
|
//#region src/Utilities/HeaderBag.d.ts
|
|
56
38
|
/**
|
|
57
39
|
* HeaderBag — A container for HTTP headers
|
|
58
|
-
* for
|
|
40
|
+
* for H3ravel App.
|
|
59
41
|
*/
|
|
60
|
-
declare class HeaderBag
|
|
42
|
+
declare class HeaderBag extends IHeaderBag {
|
|
61
43
|
protected static readonly UPPER = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
62
44
|
protected static readonly LOWER = "-abcdefghijklmnopqrstuvwxyz";
|
|
63
45
|
protected headers: Record<string, (string | null)[]>;
|
|
@@ -102,7 +84,7 @@ declare class HeaderBag implements Iterable<[string, (string | null)[]]> {
|
|
|
102
84
|
* @param defaultValue
|
|
103
85
|
* @returns
|
|
104
86
|
*/
|
|
105
|
-
get<R = undefined>(key: string, defaultValue?: string | null): R extends undefined ? string | null : R;
|
|
87
|
+
get<R = undefined>(key: string, defaultValue?: string | null | undefined): R extends undefined ? string | null | undefined : R;
|
|
106
88
|
/**
|
|
107
89
|
* Sets a header by name.
|
|
108
90
|
*
|
|
@@ -312,7 +294,7 @@ declare class ResponseHeaderBag extends HeaderBag {
|
|
|
312
294
|
}
|
|
313
295
|
//#endregion
|
|
314
296
|
//#region src/Utilities/HttpResponse.d.ts
|
|
315
|
-
declare class HttpResponse {
|
|
297
|
+
declare class HttpResponse extends IHttpResponse {
|
|
316
298
|
/**
|
|
317
299
|
* The current H3 H3Event instance
|
|
318
300
|
*/
|
|
@@ -624,13 +606,13 @@ declare class HttpResponse {
|
|
|
624
606
|
* compliant with RFC 2616. Most of the changes are based on
|
|
625
607
|
* the Request that is "associated" with this Response.
|
|
626
608
|
**/
|
|
627
|
-
prepare(request:
|
|
609
|
+
prepare(request: IRequest): this;
|
|
628
610
|
/**
|
|
629
611
|
* Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.
|
|
630
612
|
*
|
|
631
613
|
* @see http://support.microsoft.com/kb/323308
|
|
632
614
|
*/
|
|
633
|
-
protected ensureIEOverSSLCompatibility(request:
|
|
615
|
+
protected ensureIEOverSSLCompatibility(request: IRequest): void;
|
|
634
616
|
}
|
|
635
617
|
//#endregion
|
|
636
618
|
//#region src/Exceptions/HttpResponseException.d.ts
|
|
@@ -708,11 +690,12 @@ declare class FormRequest {
|
|
|
708
690
|
* Represents the HTTP context for a single request lifecycle.
|
|
709
691
|
* Encapsulates the application instance, request, and response objects.
|
|
710
692
|
*/
|
|
711
|
-
declare class HttpContext
|
|
693
|
+
declare class HttpContext extends IHttpContext {
|
|
712
694
|
app: IApplication;
|
|
713
695
|
request: IRequest;
|
|
714
696
|
response: IResponse;
|
|
715
697
|
private static contexts;
|
|
698
|
+
event: H3Event;
|
|
716
699
|
constructor(app: IApplication, request: IRequest, response: IResponse);
|
|
717
700
|
/**
|
|
718
701
|
* Factory method to create a new HttpContext instance from a context object.
|
|
@@ -723,7 +706,7 @@ declare class HttpContext implements HttpContext$1 {
|
|
|
723
706
|
app: IApplication;
|
|
724
707
|
request: IRequest;
|
|
725
708
|
response: IResponse;
|
|
726
|
-
}, event?:
|
|
709
|
+
}, event?: H3Event): HttpContext;
|
|
727
710
|
/**
|
|
728
711
|
* Retrieve an existing HttpContext instance for an event, if any.
|
|
729
712
|
*/
|
|
@@ -734,16 +717,236 @@ declare class HttpContext implements HttpContext$1 {
|
|
|
734
717
|
static forget(event: unknown): void;
|
|
735
718
|
}
|
|
736
719
|
//#endregion
|
|
720
|
+
//#region src/Utilities/Responsable.d.ts
|
|
721
|
+
declare class Responsable extends IResponsable {
|
|
722
|
+
toResponse(request: IRequest): IResponse;
|
|
723
|
+
HTTPResponse(): HTTPResponse;
|
|
724
|
+
}
|
|
725
|
+
//#endregion
|
|
726
|
+
//#region src/Response.d.ts
|
|
727
|
+
declare class Response extends HttpResponse implements IResponse {
|
|
728
|
+
app: IApplication;
|
|
729
|
+
static codes: typeof ResponseCodes;
|
|
730
|
+
private initializationData;
|
|
731
|
+
/**
|
|
732
|
+
* The current Http Context
|
|
733
|
+
*/
|
|
734
|
+
context: IHttpContext;
|
|
735
|
+
/**
|
|
736
|
+
*
|
|
737
|
+
* @param app The current app instance
|
|
738
|
+
* @param content The current H3 H3Event instance
|
|
739
|
+
* @param status The http status code
|
|
740
|
+
* @param headers The http headers
|
|
741
|
+
*/
|
|
742
|
+
constructor(app: IApplication, content: H3Event);
|
|
743
|
+
constructor(app: IApplication, content: string, status?: ResponseCodes, headers?: Record<string, (string | null)[] | string>);
|
|
744
|
+
/**
|
|
745
|
+
* Sends content for the current web response.
|
|
746
|
+
*/
|
|
747
|
+
sendContent(type?: 'html' | 'json' | 'text' | 'xml', parse?: boolean): Responsable;
|
|
748
|
+
/**
|
|
749
|
+
* Sends content for the current web response.
|
|
750
|
+
*/
|
|
751
|
+
send(type?: 'html' | 'json' | 'text' | 'xml'): Responsable;
|
|
752
|
+
/**
|
|
753
|
+
* Use an edge view as content
|
|
754
|
+
*
|
|
755
|
+
* @param viewPath The path to the view file
|
|
756
|
+
* @param send if set to true, the content will be returned, instead of the Response instance
|
|
757
|
+
* @returns
|
|
758
|
+
*/
|
|
759
|
+
view(viewPath: string, data?: Record<string, any> | undefined): Promise<this>;
|
|
760
|
+
view(viewPath: string, data: Record<string, any> | undefined, parse: boolean): Promise<Responsable>;
|
|
761
|
+
/**
|
|
762
|
+
*
|
|
763
|
+
* Parse content as edge view
|
|
764
|
+
*
|
|
765
|
+
* @param content The content to serve
|
|
766
|
+
* @param send if set to true, the content will be returned, instead of the Response instance
|
|
767
|
+
* @returns
|
|
768
|
+
*/
|
|
769
|
+
viewTemplate(content: string, data?: Record<string, any> | undefined): Promise<this>;
|
|
770
|
+
viewTemplate(content: string, data: Record<string, any> | undefined, parse: boolean): Promise<Responsable>;
|
|
771
|
+
/**
|
|
772
|
+
*
|
|
773
|
+
* @param content The content to serve
|
|
774
|
+
* @param send if set to true, the content will be returned, instead of the Response instance
|
|
775
|
+
* @returns
|
|
776
|
+
*/
|
|
777
|
+
html(content?: string): this;
|
|
778
|
+
html(content: string, parse: boolean): Responsable;
|
|
779
|
+
/**
|
|
780
|
+
* Send a JSON response.
|
|
781
|
+
*/
|
|
782
|
+
json<T = unknown>(data?: T): this;
|
|
783
|
+
json<T = unknown>(data: T, parse: boolean): Responsable;
|
|
784
|
+
/**
|
|
785
|
+
* Send plain text.
|
|
786
|
+
*/
|
|
787
|
+
text(content?: string): this;
|
|
788
|
+
text(content: string, parse: boolean): Responsable;
|
|
789
|
+
/**
|
|
790
|
+
* Send plain xml.
|
|
791
|
+
*/
|
|
792
|
+
xml(data?: string): this;
|
|
793
|
+
xml(data: string, parse: boolean): Responsable;
|
|
794
|
+
/**
|
|
795
|
+
* Build the HTTP Response
|
|
796
|
+
*
|
|
797
|
+
* @param contentType
|
|
798
|
+
* @param data
|
|
799
|
+
*/
|
|
800
|
+
private httpResponse;
|
|
801
|
+
/**
|
|
802
|
+
* Redirect to another URL.
|
|
803
|
+
*/
|
|
804
|
+
redirect(location: string, status?: number, statusText?: string | undefined): this;
|
|
805
|
+
/**
|
|
806
|
+
* Dump the response.
|
|
807
|
+
*/
|
|
808
|
+
dump(): this;
|
|
809
|
+
/**
|
|
810
|
+
* Get the base event
|
|
811
|
+
*/
|
|
812
|
+
getEvent(): H3Event;
|
|
813
|
+
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
814
|
+
/**
|
|
815
|
+
* Reset the response class to it's defautl
|
|
816
|
+
*/
|
|
817
|
+
reset(): this;
|
|
818
|
+
}
|
|
819
|
+
//#endregion
|
|
820
|
+
//#region src/JsonResponse.d.ts
|
|
821
|
+
type Data = string | number | GenericObject | ClassConstructor | any[];
|
|
822
|
+
/**
|
|
823
|
+
* Response represents an HTTP response in JSON format.
|
|
824
|
+
*
|
|
825
|
+
* Note that this class does not force the returned JSON content to be an
|
|
826
|
+
* object. It is however recommended that you do return an object as it
|
|
827
|
+
* protects yourself against XSSI and JSON-JavaScript Hijacking.
|
|
828
|
+
*
|
|
829
|
+
* @see https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/AJAX_Security_Cheat_Sheet.md#always-return-json-with-an-object-on-the-outside
|
|
830
|
+
*/
|
|
831
|
+
declare class JsonResponse extends Response {
|
|
832
|
+
protected data: Data;
|
|
833
|
+
protected callback?: string;
|
|
834
|
+
/**
|
|
835
|
+
* @param bool $json If the data is already a JSON string
|
|
836
|
+
*/
|
|
837
|
+
constructor(app: IApplication, data?: Data, status?: ResponseCodes, headers?: Record<string, (string | null)[] | string>, json?: boolean);
|
|
838
|
+
/**
|
|
839
|
+
* Sets the JSONP callback.
|
|
840
|
+
*
|
|
841
|
+
* @param callback The JSONP callback or null to use none
|
|
842
|
+
*
|
|
843
|
+
* @throws {InvalidArgumentException} When the callback name is not valid
|
|
844
|
+
*/
|
|
845
|
+
setCallback(callback?: string): this;
|
|
846
|
+
/**
|
|
847
|
+
* Factory method for chainability.
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
*
|
|
851
|
+
* return JsonResponse.fromJsonString('{"key": "value"}').setSharedMaxAge(300);
|
|
852
|
+
*
|
|
853
|
+
* @param data The JSON response string
|
|
854
|
+
* @param status The response status code (200 "OK" by default)
|
|
855
|
+
* @param headers An array of response headers
|
|
856
|
+
*/
|
|
857
|
+
static fromJsonString(app: IApplication, data: string, status?: ResponseCodes, headers?: Record<string, (string | null)[] | string>): JsonResponse;
|
|
858
|
+
/**
|
|
859
|
+
* Sets a raw string containing a JSON document to be sent.
|
|
860
|
+
*
|
|
861
|
+
* @param json
|
|
862
|
+
* @returns
|
|
863
|
+
*/
|
|
864
|
+
setJson(json: Data): this;
|
|
865
|
+
/**
|
|
866
|
+
* Sets the data to be sent as JSON.
|
|
867
|
+
*
|
|
868
|
+
* @param data
|
|
869
|
+
* @returns
|
|
870
|
+
*/
|
|
871
|
+
setData(data?: any): this;
|
|
872
|
+
/**
|
|
873
|
+
* Get the json_decoded data from the response.
|
|
874
|
+
*
|
|
875
|
+
* @param assoc
|
|
876
|
+
*/
|
|
877
|
+
getData(): any;
|
|
878
|
+
/**
|
|
879
|
+
* Sets the JSONP callback.
|
|
880
|
+
*
|
|
881
|
+
* @param callback
|
|
882
|
+
*/
|
|
883
|
+
withCallback(callback?: string): this;
|
|
884
|
+
/**
|
|
885
|
+
* Updates the content and headers according to the JSON data and callback.
|
|
886
|
+
*/
|
|
887
|
+
protected update(): this;
|
|
888
|
+
}
|
|
889
|
+
//#endregion
|
|
737
890
|
//#region src/Middleware.d.ts
|
|
738
|
-
declare abstract class Middleware
|
|
739
|
-
|
|
891
|
+
declare abstract class Middleware extends IMiddleware {
|
|
892
|
+
protected app?: IApplication | undefined;
|
|
893
|
+
constructor(app?: IApplication | undefined);
|
|
894
|
+
}
|
|
895
|
+
//#endregion
|
|
896
|
+
//#region src/Middleware/FlashDataMiddleware.d.ts
|
|
897
|
+
declare class FlashDataMiddleware extends Middleware {
|
|
898
|
+
handle(request: Request, next: (request: Request) => Promise<unknown>): Promise<unknown>;
|
|
740
899
|
}
|
|
741
900
|
//#endregion
|
|
742
901
|
//#region src/Middleware/LogRequests.d.ts
|
|
743
902
|
declare class LogRequests extends Middleware {
|
|
744
|
-
handle(
|
|
745
|
-
|
|
746
|
-
|
|
903
|
+
handle(request: IRequest, next: (request: IRequest) => Promise<unknown>): Promise<unknown>;
|
|
904
|
+
}
|
|
905
|
+
//#endregion
|
|
906
|
+
//#region src/Middleware/TrustHosts.d.ts
|
|
907
|
+
declare class TrustHosts extends Middleware {
|
|
908
|
+
/**
|
|
909
|
+
* The trusted hosts that have been configured to always be trusted.
|
|
910
|
+
*/
|
|
911
|
+
protected static alwaysTrust?: string[] | ((...arg: any[]) => string[]);
|
|
912
|
+
/**
|
|
913
|
+
* Indicates whether subdomains of the application URL should be trusted.
|
|
914
|
+
*/
|
|
915
|
+
protected static subdomains?: boolean;
|
|
916
|
+
/**
|
|
917
|
+
* Get the host patterns that should be trusted.
|
|
918
|
+
*/
|
|
919
|
+
hosts(): (string | undefined)[];
|
|
920
|
+
/**
|
|
921
|
+
* Handle the incoming request.
|
|
922
|
+
*
|
|
923
|
+
* @param request
|
|
924
|
+
* @param next
|
|
925
|
+
*/
|
|
926
|
+
handle(request: Request, next: (request: Request) => Promise<unknown>): Promise<unknown>;
|
|
927
|
+
/**
|
|
928
|
+
* Specify the hosts that should always be trusted.
|
|
929
|
+
*
|
|
930
|
+
* @param hosts
|
|
931
|
+
* @param subdomains
|
|
932
|
+
*/
|
|
933
|
+
static at(hosts: string[] | ((...arg: any[]) => string[]), subdomains?: boolean): void;
|
|
934
|
+
/**
|
|
935
|
+
* Determine if the application should specify trusted hosts.
|
|
936
|
+
*
|
|
937
|
+
* @return bool
|
|
938
|
+
*/
|
|
939
|
+
protected shouldSpecifyTrustedHosts(): boolean;
|
|
940
|
+
/**
|
|
941
|
+
* Get a regular expression matching the application URL and all of its subdomains.
|
|
942
|
+
*/
|
|
943
|
+
protected allSubdomainsOfApplicationUrl(): string | undefined;
|
|
944
|
+
/**
|
|
945
|
+
* Flush the state of the middleware.
|
|
946
|
+
*
|
|
947
|
+
* @return void
|
|
948
|
+
*/
|
|
949
|
+
static flushState(): void;
|
|
747
950
|
}
|
|
748
951
|
//#endregion
|
|
749
952
|
//#region src/Providers/HttpServiceProvider.d.ts
|
|
@@ -760,7 +963,7 @@ declare class HttpServiceProvider {
|
|
|
760
963
|
private app;
|
|
761
964
|
static priority: number;
|
|
762
965
|
registeredCommands?: (new (app: any, kernel: any) => any)[];
|
|
763
|
-
constructor(app:
|
|
966
|
+
constructor(app: IApplication);
|
|
764
967
|
register(): void;
|
|
765
968
|
boot(): void;
|
|
766
969
|
}
|
|
@@ -784,7 +987,7 @@ declare class ParamBag implements IParamBag {
|
|
|
784
987
|
/**
|
|
785
988
|
* Returns the parameters.
|
|
786
989
|
* @
|
|
787
|
-
* @param key The name of the parameter to return or
|
|
990
|
+
* @param key The name of the parameter to return or undefined to get them all
|
|
788
991
|
*
|
|
789
992
|
* @throws BadRequestException if the value is not an array
|
|
790
993
|
*/
|
|
@@ -1029,11 +1232,30 @@ declare class FileBag extends ParamBag {
|
|
|
1029
1232
|
* from the incoming request.
|
|
1030
1233
|
*/
|
|
1031
1234
|
declare class ServerBag extends ParamBag {
|
|
1235
|
+
private static serverData;
|
|
1032
1236
|
constructor(parameters: Record<string, string | undefined> | undefined,
|
|
1033
1237
|
/**
|
|
1034
1238
|
* The current H3 H3Event instance
|
|
1035
1239
|
*/
|
|
1036
1240
|
event: H3Event);
|
|
1241
|
+
static initialize(event: H3Event, headers: Record<string, string>): {
|
|
1242
|
+
SERVER_PROTOCOL?: string;
|
|
1243
|
+
REQUEST_METHOD?: string;
|
|
1244
|
+
REQUEST_URI?: string;
|
|
1245
|
+
PATH_INFO?: string;
|
|
1246
|
+
QUERY_STRING?: string;
|
|
1247
|
+
SERVER_NAME?: string;
|
|
1248
|
+
SERVER_PORT?: string;
|
|
1249
|
+
REMOTE_ADDR?: string;
|
|
1250
|
+
REMOTE_PORT?: string;
|
|
1251
|
+
HTTP_HOST?: string;
|
|
1252
|
+
HTTP_USER_AGENT?: string;
|
|
1253
|
+
HTTP_ACCEPT?: string;
|
|
1254
|
+
HTTP_ACCEPT_LANGUAGE?: string;
|
|
1255
|
+
HTTP_ACCEPT_ENCODING?: string;
|
|
1256
|
+
HTTP_REFERER?: string;
|
|
1257
|
+
HTTPS?: string;
|
|
1258
|
+
};
|
|
1037
1259
|
/**
|
|
1038
1260
|
* Returns all request headers, normalized to uppercase with underscores.
|
|
1039
1261
|
* Example: content-type → CONTENT_TYPE
|
|
@@ -1059,25 +1281,25 @@ declare class HttpRequest {
|
|
|
1059
1281
|
/**
|
|
1060
1282
|
* The current app instance
|
|
1061
1283
|
*/
|
|
1062
|
-
app:
|
|
1063
|
-
HEADER_FORWARDED: number;
|
|
1064
|
-
HEADER_X_FORWARDED_FOR: number;
|
|
1065
|
-
HEADER_X_FORWARDED_HOST: number;
|
|
1066
|
-
HEADER_X_FORWARDED_PROTO: number;
|
|
1067
|
-
HEADER_X_FORWARDED_PORT: number;
|
|
1068
|
-
HEADER_X_FORWARDED_PREFIX: number;
|
|
1069
|
-
HEADER_X_FORWARDED_AWS_ELB: number;
|
|
1070
|
-
HEADER_X_FORWARDED_TRAEFIK: number;
|
|
1071
|
-
METHOD_HEAD: string;
|
|
1072
|
-
METHOD_GET: string;
|
|
1073
|
-
METHOD_POST: string;
|
|
1074
|
-
METHOD_PUT: string;
|
|
1075
|
-
METHOD_PATCH: string;
|
|
1076
|
-
METHOD_DELETE: string;
|
|
1077
|
-
METHOD_PURGE: string;
|
|
1078
|
-
METHOD_OPTIONS: string;
|
|
1079
|
-
METHOD_TRACE: string;
|
|
1080
|
-
METHOD_CONNECT: string;
|
|
1284
|
+
app: IApplication;
|
|
1285
|
+
static HEADER_FORWARDED: number;
|
|
1286
|
+
static HEADER_X_FORWARDED_FOR: number;
|
|
1287
|
+
static HEADER_X_FORWARDED_HOST: number;
|
|
1288
|
+
static HEADER_X_FORWARDED_PROTO: number;
|
|
1289
|
+
static HEADER_X_FORWARDED_PORT: number;
|
|
1290
|
+
static HEADER_X_FORWARDED_PREFIX: number;
|
|
1291
|
+
static HEADER_X_FORWARDED_AWS_ELB: number;
|
|
1292
|
+
static HEADER_X_FORWARDED_TRAEFIK: number;
|
|
1293
|
+
static METHOD_HEAD: string;
|
|
1294
|
+
static METHOD_GET: string;
|
|
1295
|
+
static METHOD_POST: string;
|
|
1296
|
+
static METHOD_PUT: string;
|
|
1297
|
+
static METHOD_PATCH: string;
|
|
1298
|
+
static METHOD_DELETE: string;
|
|
1299
|
+
static METHOD_PURGE: string;
|
|
1300
|
+
static METHOD_OPTIONS: string;
|
|
1301
|
+
static METHOD_TRACE: string;
|
|
1302
|
+
static METHOD_CONNECT: string;
|
|
1081
1303
|
/**
|
|
1082
1304
|
* Names for headers that can be trusted when
|
|
1083
1305
|
* using trusted proxies.
|
|
@@ -1094,10 +1316,16 @@ declare class HttpRequest {
|
|
|
1094
1316
|
*/
|
|
1095
1317
|
body: unknown;
|
|
1096
1318
|
protected format?: string;
|
|
1319
|
+
protected basePath?: string;
|
|
1320
|
+
protected baseUrl?: string;
|
|
1321
|
+
protected requestUri?: string;
|
|
1322
|
+
protected pathInfo?: string;
|
|
1097
1323
|
protected formData: FormRequest;
|
|
1098
1324
|
private preferredFormat?;
|
|
1099
1325
|
private isForwardedValid;
|
|
1326
|
+
static trustedHosts: string[];
|
|
1100
1327
|
private static trustedHeaderSet;
|
|
1328
|
+
protected static trustedHostPatterns: RegExp[];
|
|
1101
1329
|
/**
|
|
1102
1330
|
* Gets route parameters.
|
|
1103
1331
|
* @returns An object containing route parameters.
|
|
@@ -1116,15 +1344,19 @@ declare class HttpRequest {
|
|
|
1116
1344
|
/**
|
|
1117
1345
|
* Query string parameters (GET).
|
|
1118
1346
|
*/
|
|
1119
|
-
|
|
1347
|
+
_query: InputBag;
|
|
1120
1348
|
/**
|
|
1121
1349
|
* Server and execution environment parameters
|
|
1122
1350
|
*/
|
|
1123
|
-
|
|
1351
|
+
_server: ServerBag;
|
|
1124
1352
|
/**
|
|
1125
1353
|
* Cookies
|
|
1126
1354
|
*/
|
|
1127
1355
|
cookies: InputBag;
|
|
1356
|
+
/**
|
|
1357
|
+
* The current Http Context
|
|
1358
|
+
*/
|
|
1359
|
+
context: IHttpContext;
|
|
1128
1360
|
/**
|
|
1129
1361
|
* The request attributes (parameters parsed from the PATH_INFO, ...).
|
|
1130
1362
|
*/
|
|
@@ -1138,6 +1370,8 @@ declare class HttpRequest {
|
|
|
1138
1370
|
protected static formats?: Record<string, string[]> | undefined | null;
|
|
1139
1371
|
protected static trustedProxies: string[];
|
|
1140
1372
|
protected static httpMethodParameterOverride: boolean;
|
|
1373
|
+
protected sessionManager: ISessionManager;
|
|
1374
|
+
protected sessionManagerClass: typeof ISessionManager;
|
|
1141
1375
|
/**
|
|
1142
1376
|
* List of Acceptable Content Types
|
|
1143
1377
|
*/
|
|
@@ -1151,7 +1385,7 @@ declare class HttpRequest {
|
|
|
1151
1385
|
/**
|
|
1152
1386
|
* The current app instance
|
|
1153
1387
|
*/
|
|
1154
|
-
app:
|
|
1388
|
+
app: IApplication);
|
|
1155
1389
|
/**
|
|
1156
1390
|
* Sets the parameters for this request.
|
|
1157
1391
|
*
|
|
@@ -1163,7 +1397,8 @@ declare class HttpRequest {
|
|
|
1163
1397
|
* @param server The SERVER parameters
|
|
1164
1398
|
* @param content The raw body data
|
|
1165
1399
|
*/
|
|
1166
|
-
initialize():
|
|
1400
|
+
initialize(): void;
|
|
1401
|
+
protected buildRequirements(): void;
|
|
1167
1402
|
/**
|
|
1168
1403
|
* Gets a list of content types acceptable by the client browser in preferable order.
|
|
1169
1404
|
* @returns {string[]}
|
|
@@ -1172,7 +1407,82 @@ declare class HttpRequest {
|
|
|
1172
1407
|
/**
|
|
1173
1408
|
* Get a URI instance for the request.
|
|
1174
1409
|
*/
|
|
1175
|
-
getUriInstance():
|
|
1410
|
+
getUriInstance(): IUrl;
|
|
1411
|
+
/**
|
|
1412
|
+
* Returns the requested URI (path and query string).
|
|
1413
|
+
*
|
|
1414
|
+
* @return {string} The raw URI (i.e. not URI decoded)
|
|
1415
|
+
*/
|
|
1416
|
+
getRequestUri(): string;
|
|
1417
|
+
/**
|
|
1418
|
+
* Gets the scheme and HTTP host.
|
|
1419
|
+
*
|
|
1420
|
+
* If the URL was called with basic authentication, the user
|
|
1421
|
+
* and the password are not added to the generated string.
|
|
1422
|
+
*/
|
|
1423
|
+
getSchemeAndHttpHost(): string;
|
|
1424
|
+
/**
|
|
1425
|
+
* Returns the HTTP host being requested.
|
|
1426
|
+
*
|
|
1427
|
+
* The port name will be appended to the host if it's non-standard.
|
|
1428
|
+
*/
|
|
1429
|
+
getHttpHost(): string;
|
|
1430
|
+
/**
|
|
1431
|
+
* Returns the root path from which this request is executed.
|
|
1432
|
+
*
|
|
1433
|
+
* @returns {string} The raw path (i.e. not urldecoded)
|
|
1434
|
+
*/
|
|
1435
|
+
getBasePath(): string;
|
|
1436
|
+
/**
|
|
1437
|
+
* Returns the root URL from which this request is executed.
|
|
1438
|
+
*
|
|
1439
|
+
* The base URL never ends with a /.
|
|
1440
|
+
*
|
|
1441
|
+
* This is similar to getBasePath(), except that it also includes the
|
|
1442
|
+
* script filename (e.g. index.php) if one exists.
|
|
1443
|
+
*
|
|
1444
|
+
* @return string The raw URL (i.e. not urldecoded)
|
|
1445
|
+
*/
|
|
1446
|
+
getBaseUrl(): string;
|
|
1447
|
+
/**
|
|
1448
|
+
* Returns the real base URL received by the webserver from which this request is executed.
|
|
1449
|
+
* The URL does not include trusted reverse proxy prefix.
|
|
1450
|
+
*
|
|
1451
|
+
* @return string The raw URL (i.e. not urldecoded)
|
|
1452
|
+
*/
|
|
1453
|
+
private getBaseUrlReal;
|
|
1454
|
+
/**
|
|
1455
|
+
* Gets the request's scheme.
|
|
1456
|
+
*/
|
|
1457
|
+
getScheme(): string;
|
|
1458
|
+
/**
|
|
1459
|
+
* Prepares the base URL.
|
|
1460
|
+
*/
|
|
1461
|
+
protected prepareBaseUrl(): string;
|
|
1462
|
+
/**
|
|
1463
|
+
* Prepares the Request URI.
|
|
1464
|
+
*/
|
|
1465
|
+
protected prepareRequestUri(): string;
|
|
1466
|
+
/**
|
|
1467
|
+
* Prepares the base path.
|
|
1468
|
+
*/
|
|
1469
|
+
protected prepareBasePath(): string;
|
|
1470
|
+
/**
|
|
1471
|
+
* Prepares the path info.
|
|
1472
|
+
*/
|
|
1473
|
+
protected preparePathInfo(): string;
|
|
1474
|
+
/**
|
|
1475
|
+
* Returns the port on which the request is made.
|
|
1476
|
+
*
|
|
1477
|
+
* This method can read the client port from the "X-Forwarded-Port" header
|
|
1478
|
+
* when trusted proxies were set via "setTrustedProxies()".
|
|
1479
|
+
*
|
|
1480
|
+
* The "X-Forwarded-Port" header must contain the client port.
|
|
1481
|
+
*
|
|
1482
|
+
* @return int|string|null Can be a string if fetched from the server bag
|
|
1483
|
+
*/
|
|
1484
|
+
getPort(): number | string | undefined;
|
|
1485
|
+
getHost(): string;
|
|
1176
1486
|
/**
|
|
1177
1487
|
* Checks whether the request is secure or not.
|
|
1178
1488
|
*
|
|
@@ -1182,6 +1492,13 @@ declare class HttpRequest {
|
|
|
1182
1492
|
* The "X-Forwarded-Proto" header must contain the protocol: "https" or "http".
|
|
1183
1493
|
*/
|
|
1184
1494
|
isSecure(): boolean;
|
|
1495
|
+
/**
|
|
1496
|
+
* Is this IIS with UrlRewriteModule?
|
|
1497
|
+
*
|
|
1498
|
+
* This method consumes, caches and removed the IIS_WasUrlRewritten env var,
|
|
1499
|
+
* so we don't inherit it to sub-requests.
|
|
1500
|
+
*/
|
|
1501
|
+
private isIisRewrite;
|
|
1185
1502
|
/**
|
|
1186
1503
|
* Returns the value of the requested header.
|
|
1187
1504
|
*/
|
|
@@ -1212,6 +1529,10 @@ declare class HttpRequest {
|
|
|
1212
1529
|
* Returns true if the request is an XMLHttpRequest (AJAX).
|
|
1213
1530
|
*/
|
|
1214
1531
|
isXmlHttpRequest(): boolean;
|
|
1532
|
+
/**
|
|
1533
|
+
* See https://url.spec.whatwg.org/.
|
|
1534
|
+
*/
|
|
1535
|
+
private static isHostValid;
|
|
1215
1536
|
/**
|
|
1216
1537
|
* Initializes HTTP request formats.
|
|
1217
1538
|
*/
|
|
@@ -1305,11 +1626,37 @@ declare class HttpRequest {
|
|
|
1305
1626
|
isFromTrustedProxy(): boolean;
|
|
1306
1627
|
/**
|
|
1307
1628
|
* This method is rather heavy because it splits and merges headers, and it's called by many other methods such as
|
|
1308
|
-
* getPort(), isSecure(), getHost(), getClientIps(),
|
|
1629
|
+
* getPort(), isSecure(), getHost(), getClientIps(), this.() etc. Thus, we try to cache the results for
|
|
1309
1630
|
* best performance.
|
|
1310
1631
|
*/
|
|
1311
1632
|
private getTrustedValues;
|
|
1633
|
+
/**
|
|
1634
|
+
*
|
|
1635
|
+
* @param clientIps
|
|
1636
|
+
* @param ip
|
|
1637
|
+
* @returns
|
|
1638
|
+
*/
|
|
1312
1639
|
private normalizeAndFilterClientIps;
|
|
1640
|
+
/**
|
|
1641
|
+
* Sets a list of trusted host patterns.
|
|
1642
|
+
*
|
|
1643
|
+
* You should only list the hosts you manage using regexes.
|
|
1644
|
+
*
|
|
1645
|
+
* @param hostPatterns
|
|
1646
|
+
*/
|
|
1647
|
+
static setTrustedHosts(hostPatterns: string[]): void;
|
|
1648
|
+
/**
|
|
1649
|
+
* Returns the path being requested relative to the executed script.
|
|
1650
|
+
*
|
|
1651
|
+
* The path info always starts with a /.
|
|
1652
|
+
*
|
|
1653
|
+
* @return {string} The raw path (i.e. not urldecoded)
|
|
1654
|
+
*/
|
|
1655
|
+
getPathInfo(): string;
|
|
1656
|
+
/**
|
|
1657
|
+
* Gets the list of trusted host patterns.
|
|
1658
|
+
*/
|
|
1659
|
+
static getTrustedHosts(): RegExp[];
|
|
1313
1660
|
/**
|
|
1314
1661
|
* Enables support for the _method request parameter to determine the intended HTTP method.
|
|
1315
1662
|
*
|
|
@@ -1329,12 +1676,20 @@ declare class HttpRequest {
|
|
|
1329
1676
|
}
|
|
1330
1677
|
//#endregion
|
|
1331
1678
|
//#region src/Request.d.ts
|
|
1332
|
-
declare class Request extends HttpRequest implements IRequest {
|
|
1679
|
+
declare class Request<D extends Record<string, any> = Record<string, any>, R extends RulesForData<D> = RulesForData<D>, U extends Record<string, any> = Record<string, any>> extends HttpRequest implements IRequest<D, R> {
|
|
1333
1680
|
#private;
|
|
1334
1681
|
/**
|
|
1335
1682
|
* All of the converted files for the request.
|
|
1336
1683
|
*/
|
|
1337
1684
|
protected convertedFiles?: Record<string, UploadedFile | UploadedFile[]>;
|
|
1685
|
+
/**
|
|
1686
|
+
* The route resolver callback.
|
|
1687
|
+
*/
|
|
1688
|
+
protected routeResolver?: () => IRoute;
|
|
1689
|
+
/**
|
|
1690
|
+
* The user resolver callback.
|
|
1691
|
+
*/
|
|
1692
|
+
protected userResolver?: (guard?: string) => U;
|
|
1338
1693
|
constructor(
|
|
1339
1694
|
/**
|
|
1340
1695
|
* The current H3 H3Event instance
|
|
@@ -1343,7 +1698,7 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1343
1698
|
/**
|
|
1344
1699
|
* The current app instance
|
|
1345
1700
|
*/
|
|
1346
|
-
app:
|
|
1701
|
+
app: IApplication);
|
|
1347
1702
|
/**
|
|
1348
1703
|
* Factory method to create a Request instance from an H3Event.
|
|
1349
1704
|
*/
|
|
@@ -1355,8 +1710,28 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1355
1710
|
/**
|
|
1356
1711
|
* The current app instance
|
|
1357
1712
|
*/
|
|
1358
|
-
app:
|
|
1713
|
+
app: IApplication): Promise<Request<Record<string, any>, Partial<Record<string, _h3ravel_contracts0.ValidationRuleSet>>, Record<string, any>>>;
|
|
1714
|
+
/**
|
|
1715
|
+
* Factory method to create a syncronous Request instance from an H3Event.
|
|
1716
|
+
*/
|
|
1717
|
+
static createSync(
|
|
1718
|
+
/**
|
|
1719
|
+
* The current H3 H3Event instance
|
|
1720
|
+
*/
|
|
1721
|
+
event: H3Event,
|
|
1722
|
+
/**
|
|
1723
|
+
* The current app instance
|
|
1724
|
+
*/
|
|
1725
|
+
app: IApplication): Request<Record<string, any>, Partial<Record<string, _h3ravel_contracts0.ValidationRuleSet>>, Record<string, any>>;
|
|
1359
1726
|
private setBody;
|
|
1727
|
+
/**
|
|
1728
|
+
* Validate the incoming request data
|
|
1729
|
+
*
|
|
1730
|
+
* @param data
|
|
1731
|
+
* @param rules
|
|
1732
|
+
* @param messages
|
|
1733
|
+
*/
|
|
1734
|
+
validate(rules: R, messages?: Partial<Record<MessagesForRules<R>, string>>): Promise<D>;
|
|
1360
1735
|
/**
|
|
1361
1736
|
* Retrieve all data from the instance (query + body).
|
|
1362
1737
|
*/
|
|
@@ -1382,7 +1757,24 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1382
1757
|
* @param expectArray set to true to return an `UploadedFile[]` array.
|
|
1383
1758
|
* @returns
|
|
1384
1759
|
*/
|
|
1385
|
-
file
|
|
1760
|
+
file(): Record<string, UploadedFile>;
|
|
1761
|
+
file(key?: undefined, defaultValue?: any, expectArray?: true): Record<string, UploadedFile[]>;
|
|
1762
|
+
file(key: string, defaultValue?: any, expectArray?: false | undefined): UploadedFile;
|
|
1763
|
+
file(key: string, defaultValue?: any, expectArray?: true): UploadedFile[];
|
|
1764
|
+
/**
|
|
1765
|
+
* Get the user making the request.
|
|
1766
|
+
*
|
|
1767
|
+
* @param guard
|
|
1768
|
+
*/
|
|
1769
|
+
user(guard?: string): U | undefined;
|
|
1770
|
+
/**
|
|
1771
|
+
* Get the route handling the request.
|
|
1772
|
+
*
|
|
1773
|
+
* @param param
|
|
1774
|
+
* @param defaultRoute
|
|
1775
|
+
*/
|
|
1776
|
+
route(): IRoute;
|
|
1777
|
+
route(param?: string, defaultParam?: any): any;
|
|
1386
1778
|
/**
|
|
1387
1779
|
* Determine if the uploaded data contains a file.
|
|
1388
1780
|
*
|
|
@@ -1405,6 +1797,10 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1405
1797
|
* Extract and convert uploaded files from FormData.
|
|
1406
1798
|
*/
|
|
1407
1799
|
convertUploadedFiles(files: Record<string, UploadedFile | UploadedFile[]>): Record<string, UploadedFile | UploadedFile[]>;
|
|
1800
|
+
/**
|
|
1801
|
+
* Get the current decoded path info for the request.
|
|
1802
|
+
*/
|
|
1803
|
+
decodedPath(): string;
|
|
1408
1804
|
/**
|
|
1409
1805
|
* Determine if the data contains a given key.
|
|
1410
1806
|
*
|
|
@@ -1423,6 +1819,10 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1423
1819
|
* @returns
|
|
1424
1820
|
*/
|
|
1425
1821
|
only<T = Record<string, any>>(keys: string[]): T;
|
|
1822
|
+
/**
|
|
1823
|
+
* Determine if the request is over HTTPS.
|
|
1824
|
+
*/
|
|
1825
|
+
secure(): boolean;
|
|
1426
1826
|
/**
|
|
1427
1827
|
* Get all of the data except for a specified array of items.
|
|
1428
1828
|
*
|
|
@@ -1447,6 +1847,26 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1447
1847
|
* Get the keys for all of the input and files.
|
|
1448
1848
|
*/
|
|
1449
1849
|
keys(): string[];
|
|
1850
|
+
/**
|
|
1851
|
+
* Get an instance of the current session manager
|
|
1852
|
+
*
|
|
1853
|
+
* @param key
|
|
1854
|
+
* @param defaultValue
|
|
1855
|
+
* @returns a global instance of the current session manager.
|
|
1856
|
+
*/
|
|
1857
|
+
session<K extends string | Record<string, any> | undefined = undefined>(key?: K, defaultValue?: any): K extends undefined ? ISessionManager : K extends string ? any : void | Promise<void>;
|
|
1858
|
+
/**
|
|
1859
|
+
* Get the host name.
|
|
1860
|
+
*/
|
|
1861
|
+
host(): string;
|
|
1862
|
+
/**
|
|
1863
|
+
* Get the HTTP host being requested.
|
|
1864
|
+
*/
|
|
1865
|
+
httpHost(): string;
|
|
1866
|
+
/**
|
|
1867
|
+
* Get the scheme and HTTP host.
|
|
1868
|
+
*/
|
|
1869
|
+
schemeAndHttpHost(): string;
|
|
1450
1870
|
/**
|
|
1451
1871
|
* Determine if the request is sending JSON.
|
|
1452
1872
|
*
|
|
@@ -1482,14 +1902,39 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1482
1902
|
* Get the client IP address.
|
|
1483
1903
|
*/
|
|
1484
1904
|
ip(): string | undefined;
|
|
1905
|
+
/**
|
|
1906
|
+
* Get the flashed input from previous request
|
|
1907
|
+
*
|
|
1908
|
+
* @param key
|
|
1909
|
+
* @param defaultValue
|
|
1910
|
+
* @returns
|
|
1911
|
+
*/
|
|
1912
|
+
old(): Promise<Record<string, any>>;
|
|
1913
|
+
old(key: string, defaultValue?: any): Promise<any>;
|
|
1485
1914
|
/**
|
|
1486
1915
|
* Get a URI instance for the request.
|
|
1487
1916
|
*/
|
|
1488
|
-
uri():
|
|
1917
|
+
uri(): IUrl;
|
|
1918
|
+
/**
|
|
1919
|
+
* Get the root URL for the application.
|
|
1920
|
+
*
|
|
1921
|
+
* @return string
|
|
1922
|
+
*/
|
|
1923
|
+
root(): string;
|
|
1924
|
+
/**
|
|
1925
|
+
* Get the URL (no query string) for the request.
|
|
1926
|
+
*
|
|
1927
|
+
* @return string
|
|
1928
|
+
*/
|
|
1929
|
+
url(): string;
|
|
1489
1930
|
/**
|
|
1490
1931
|
* Get the full URL for the request.
|
|
1491
1932
|
*/
|
|
1492
1933
|
fullUrl(): string;
|
|
1934
|
+
/**
|
|
1935
|
+
* Get the current path info for the request.
|
|
1936
|
+
*/
|
|
1937
|
+
path(): string;
|
|
1493
1938
|
/**
|
|
1494
1939
|
* Return the Request instance.
|
|
1495
1940
|
*/
|
|
@@ -1506,12 +1951,98 @@ declare class Request extends HttpRequest implements IRequest {
|
|
|
1506
1951
|
* @return {InputBag}
|
|
1507
1952
|
*/
|
|
1508
1953
|
json<K extends string | undefined = undefined>(key?: string, defaultValue?: any): K extends undefined ? InputBag : any;
|
|
1954
|
+
/**
|
|
1955
|
+
* Get the user resolver callback.
|
|
1956
|
+
*/
|
|
1957
|
+
getUserResolver(): ((gaurd?: string) => U | undefined);
|
|
1958
|
+
/**
|
|
1959
|
+
* Set the user resolver callback.
|
|
1960
|
+
*
|
|
1961
|
+
* @param callback
|
|
1962
|
+
*/
|
|
1963
|
+
setUserResolver(callback: (gaurd?: string) => U): this;
|
|
1964
|
+
/**
|
|
1965
|
+
* Get the route resolver callback.
|
|
1966
|
+
*/
|
|
1967
|
+
getRouteResolver(): () => IRoute | undefined;
|
|
1968
|
+
/**
|
|
1969
|
+
* Set the route resolver callback.
|
|
1970
|
+
*
|
|
1971
|
+
* @param callback
|
|
1972
|
+
*/
|
|
1973
|
+
setRouteResolver(callback: () => IRoute): this;
|
|
1974
|
+
/**
|
|
1975
|
+
* Get the bearer token from the request headers.
|
|
1976
|
+
*/
|
|
1977
|
+
bearerToken(): string | undefined;
|
|
1978
|
+
/**
|
|
1979
|
+
* Retrieve data from the instance.
|
|
1980
|
+
*
|
|
1981
|
+
* @param key
|
|
1982
|
+
* @param defaultValue
|
|
1983
|
+
*/
|
|
1984
|
+
protected data(key?: string, defaultValue?: any): any;
|
|
1985
|
+
/**
|
|
1986
|
+
* Retrieve a request payload item from the request.
|
|
1987
|
+
*
|
|
1988
|
+
* @param key
|
|
1989
|
+
* @param default
|
|
1990
|
+
*/
|
|
1991
|
+
post(key?: string, defaultValue?: any): any;
|
|
1992
|
+
/**
|
|
1993
|
+
* Determine if a header is set on the request.
|
|
1994
|
+
*
|
|
1995
|
+
* @param key
|
|
1996
|
+
*/
|
|
1997
|
+
hasHeader(key: string): boolean;
|
|
1998
|
+
/**
|
|
1999
|
+
* Retrieve a header from the request.
|
|
2000
|
+
*
|
|
2001
|
+
* @param key
|
|
2002
|
+
* @param default
|
|
2003
|
+
*/
|
|
2004
|
+
header(key?: string, defaultValue?: any): any;
|
|
2005
|
+
/**
|
|
2006
|
+
* Determine if a cookie is set on the request.
|
|
2007
|
+
*
|
|
2008
|
+
* @param string $key
|
|
2009
|
+
*/
|
|
2010
|
+
hasCookie(key: string): boolean;
|
|
2011
|
+
/**
|
|
2012
|
+
* Retrieve a cookie from the request.
|
|
2013
|
+
*
|
|
2014
|
+
* @param key
|
|
2015
|
+
* @param default
|
|
2016
|
+
*/
|
|
2017
|
+
cookie(key?: string, defaultValue?: any): any;
|
|
2018
|
+
/**
|
|
2019
|
+
* Retrieve a query string item from the request.
|
|
2020
|
+
*
|
|
2021
|
+
* @param key
|
|
2022
|
+
* @param default
|
|
2023
|
+
*/
|
|
2024
|
+
query(key?: string, defaultValue?: any): any;
|
|
2025
|
+
/**
|
|
2026
|
+
* Retrieve a server variable from the request.
|
|
2027
|
+
*
|
|
2028
|
+
* @param key
|
|
2029
|
+
* @param default
|
|
2030
|
+
*/
|
|
2031
|
+
server(key?: string, defaultValue?: any): any;
|
|
1509
2032
|
/**
|
|
1510
2033
|
* Get the input source for the request.
|
|
1511
2034
|
*
|
|
1512
2035
|
* @return {InputBag}
|
|
1513
2036
|
*/
|
|
1514
2037
|
protected getInputSource(): InputBag;
|
|
2038
|
+
/**
|
|
2039
|
+
* Retrieve a parameter item from a given source.
|
|
2040
|
+
*
|
|
2041
|
+
* @param source
|
|
2042
|
+
* @param key
|
|
2043
|
+
* @param defaultValue
|
|
2044
|
+
*/
|
|
2045
|
+
protected retrieveItem(source: 'cookies' | '_server' | 'request' | '_query' | 'headers' | 'files' | 'attributes', key?: string, defaultValue?: any): any;
|
|
1515
2046
|
/**
|
|
1516
2047
|
* Dump the items.
|
|
1517
2048
|
*
|
|
@@ -1620,74 +2151,6 @@ declare class JsonResource<R extends Resource = any> {
|
|
|
1620
2151
|
//#region src/Resources/ApiResource.d.ts
|
|
1621
2152
|
declare function ApiResource(instance: JsonResource): JsonResource<any>;
|
|
1622
2153
|
//#endregion
|
|
1623
|
-
//#region src/Response.d.ts
|
|
1624
|
-
declare class Response extends HttpResponse implements IResponse {
|
|
1625
|
-
/**
|
|
1626
|
-
* The current app instance
|
|
1627
|
-
*/
|
|
1628
|
-
app: Application;
|
|
1629
|
-
constructor(
|
|
1630
|
-
/**
|
|
1631
|
-
* The current H3 H3Event instance
|
|
1632
|
-
*/
|
|
1633
|
-
event: H3Event,
|
|
1634
|
-
/**
|
|
1635
|
-
* The current app instance
|
|
1636
|
-
*/
|
|
1637
|
-
app: Application);
|
|
1638
|
-
/**
|
|
1639
|
-
* Sends content for the current web response.
|
|
1640
|
-
*/
|
|
1641
|
-
sendContent(type?: 'html' | 'json' | 'text' | 'xml', parse?: boolean): unknown;
|
|
1642
|
-
/**
|
|
1643
|
-
* Sends content for the current web response.
|
|
1644
|
-
*/
|
|
1645
|
-
send(type?: 'html' | 'json' | 'text' | 'xml'): unknown;
|
|
1646
|
-
/**
|
|
1647
|
-
*
|
|
1648
|
-
* @param content The content to serve
|
|
1649
|
-
* @param send if set to true, the content will be returned, instead of the Response instance
|
|
1650
|
-
* @returns
|
|
1651
|
-
*/
|
|
1652
|
-
html(content?: string): this;
|
|
1653
|
-
html(content: string, parse: boolean): HTTPResponse;
|
|
1654
|
-
/**
|
|
1655
|
-
* Send a JSON response.
|
|
1656
|
-
*/
|
|
1657
|
-
json<T = unknown>(data?: T): this;
|
|
1658
|
-
json<T = unknown>(data: T, parse: boolean): T;
|
|
1659
|
-
/**
|
|
1660
|
-
* Send plain text.
|
|
1661
|
-
*/
|
|
1662
|
-
text(content?: string): this;
|
|
1663
|
-
text(content: string, parse: boolean): HTTPResponse;
|
|
1664
|
-
/**
|
|
1665
|
-
* Send plain xml.
|
|
1666
|
-
*/
|
|
1667
|
-
xml(data?: string): this;
|
|
1668
|
-
xml(data: string, parse: boolean): HTTPResponse;
|
|
1669
|
-
/**
|
|
1670
|
-
* Build the HTTP Response
|
|
1671
|
-
*
|
|
1672
|
-
* @param contentType
|
|
1673
|
-
* @param data
|
|
1674
|
-
*/
|
|
1675
|
-
private httpResponse;
|
|
1676
|
-
/**
|
|
1677
|
-
* Redirect to another URL.
|
|
1678
|
-
*/
|
|
1679
|
-
redirect(location: string, status?: number, statusText?: string | undefined): HTTPResponse;
|
|
1680
|
-
/**
|
|
1681
|
-
* Dump the response.
|
|
1682
|
-
*/
|
|
1683
|
-
dump(): this;
|
|
1684
|
-
/**
|
|
1685
|
-
* Get the base event
|
|
1686
|
-
*/
|
|
1687
|
-
getEvent(): H3Event;
|
|
1688
|
-
getEvent<K extends DotNestedKeys<H3Event>>(key: K): DotNestedValue<H3Event, K>;
|
|
1689
|
-
}
|
|
1690
|
-
//#endregion
|
|
1691
2154
|
//#region src/Utilities/HeaderUtility.d.ts
|
|
1692
2155
|
/**
|
|
1693
2156
|
* HTTP header utility functions .
|
|
@@ -1793,105 +2256,4 @@ declare class IpUtils {
|
|
|
1793
2256
|
private static setCacheResult;
|
|
1794
2257
|
}
|
|
1795
2258
|
//#endregion
|
|
1796
|
-
|
|
1797
|
-
declare enum ResponseCodes {
|
|
1798
|
-
HTTP_CONTINUE = 100,
|
|
1799
|
-
HTTP_SWITCHING_PROTOCOLS = 101,
|
|
1800
|
-
HTTP_PROCESSING = 102,
|
|
1801
|
-
// RFC2518
|
|
1802
|
-
HTTP_EARLY_HINTS = 103,
|
|
1803
|
-
// RFC8297
|
|
1804
|
-
HTTP_OK = 200,
|
|
1805
|
-
HTTP_CREATED = 201,
|
|
1806
|
-
HTTP_ACCEPTED = 202,
|
|
1807
|
-
HTTP_NON_AUTHORITATIVE_INFORMATION = 203,
|
|
1808
|
-
HTTP_NO_CONTENT = 204,
|
|
1809
|
-
HTTP_RESET_CONTENT = 205,
|
|
1810
|
-
HTTP_PARTIAL_CONTENT = 206,
|
|
1811
|
-
HTTP_MULTI_STATUS = 207,
|
|
1812
|
-
// RFC4918
|
|
1813
|
-
HTTP_ALREADY_REPORTED = 208,
|
|
1814
|
-
// RFC5842
|
|
1815
|
-
HTTP_IM_USED = 226,
|
|
1816
|
-
// RFC3229
|
|
1817
|
-
HTTP_MULTIPLE_CHOICES = 300,
|
|
1818
|
-
HTTP_MOVED_PERMANENTLY = 301,
|
|
1819
|
-
HTTP_FOUND = 302,
|
|
1820
|
-
HTTP_SEE_OTHER = 303,
|
|
1821
|
-
HTTP_NOT_MODIFIED = 304,
|
|
1822
|
-
HTTP_USE_PROXY = 305,
|
|
1823
|
-
HTTP_RESERVED = 306,
|
|
1824
|
-
HTTP_TEMPORARY_REDIRECT = 307,
|
|
1825
|
-
HTTP_PERMANENTLY_REDIRECT = 308,
|
|
1826
|
-
// RFC7238
|
|
1827
|
-
HTTP_BAD_REQUEST = 400,
|
|
1828
|
-
HTTP_UNAUTHORIZED = 401,
|
|
1829
|
-
HTTP_PAYMENT_REQUIRED = 402,
|
|
1830
|
-
HTTP_FORBIDDEN = 403,
|
|
1831
|
-
HTTP_NOT_FOUND = 404,
|
|
1832
|
-
HTTP_METHOD_NOT_ALLOWED = 405,
|
|
1833
|
-
HTTP_NOT_ACCEPTABLE = 406,
|
|
1834
|
-
HTTP_PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
1835
|
-
HTTP_REQUEST_TIMEOUT = 408,
|
|
1836
|
-
HTTP_CONFLICT = 409,
|
|
1837
|
-
HTTP_GONE = 410,
|
|
1838
|
-
HTTP_LENGTH_REQUIRED = 411,
|
|
1839
|
-
HTTP_PRECONDITION_FAILED = 412,
|
|
1840
|
-
HTTP_REQUEST_ENTITY_TOO_LARGE = 413,
|
|
1841
|
-
HTTP_REQUEST_URI_TOO_LONG = 414,
|
|
1842
|
-
HTTP_UNSUPPORTED_MEDIA_TYPE = 415,
|
|
1843
|
-
HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
|
1844
|
-
HTTP_EXPECTATION_FAILED = 417,
|
|
1845
|
-
HTTP_I_AM_A_TEAPOT = 418,
|
|
1846
|
-
// RFC2324
|
|
1847
|
-
HTTP_MISDIRECTED_REQUEST = 421,
|
|
1848
|
-
// RFC7540
|
|
1849
|
-
HTTP_UNPROCESSABLE_ENTITY = 422,
|
|
1850
|
-
// RFC4918
|
|
1851
|
-
HTTP_LOCKED = 423,
|
|
1852
|
-
// RFC4918
|
|
1853
|
-
HTTP_FAILED_DEPENDENCY = 424,
|
|
1854
|
-
// RFC4918
|
|
1855
|
-
HTTP_TOO_EARLY = 425,
|
|
1856
|
-
// RFC-ietf-httpbis-replay-04
|
|
1857
|
-
HTTP_UPGRADE_REQUIRED = 426,
|
|
1858
|
-
// RFC2817
|
|
1859
|
-
HTTP_PRECONDITION_REQUIRED = 428,
|
|
1860
|
-
// RFC6585
|
|
1861
|
-
HTTP_TOO_MANY_REQUESTS = 429,
|
|
1862
|
-
// RFC6585
|
|
1863
|
-
HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
1864
|
-
// RFC6585
|
|
1865
|
-
HTTP_UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
1866
|
-
// RFC7725
|
|
1867
|
-
HTTP_INTERNAL_SERVER_ERROR = 500,
|
|
1868
|
-
HTTP_NOT_IMPLEMENTED = 501,
|
|
1869
|
-
HTTP_BAD_GATEWAY = 502,
|
|
1870
|
-
HTTP_SERVICE_UNAVAILABLE = 503,
|
|
1871
|
-
HTTP_GATEWAY_TIMEOUT = 504,
|
|
1872
|
-
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
1873
|
-
HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506,
|
|
1874
|
-
// RFC2295
|
|
1875
|
-
HTTP_INSUFFICIENT_STORAGE = 507,
|
|
1876
|
-
// RFC4918
|
|
1877
|
-
HTTP_LOOP_DETECTED = 508,
|
|
1878
|
-
// RFC5842
|
|
1879
|
-
HTTP_NOT_EXTENDED = 510,
|
|
1880
|
-
// RFC2774
|
|
1881
|
-
HTTP_NETWORK_AUTHENTICATION_REQUIRED = 511,
|
|
1882
|
-
}
|
|
1883
|
-
declare const HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES: CacheOptions;
|
|
1884
|
-
/**
|
|
1885
|
-
* Status codes translation table.
|
|
1886
|
-
*
|
|
1887
|
-
* The list of codes is complete according to the
|
|
1888
|
-
* @link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml Hypertext Transfer Protocol (HTTP) Status Code Registry
|
|
1889
|
-
* (last updated 2021-10-01).
|
|
1890
|
-
*
|
|
1891
|
-
* Unless otherwise noted, the status code is defined in RFC2616.
|
|
1892
|
-
*/
|
|
1893
|
-
declare const statusTexts: {
|
|
1894
|
-
[key: number]: string;
|
|
1895
|
-
};
|
|
1896
|
-
//#endregion
|
|
1897
|
-
export { ApiResource, BadRequestException, CacheOptions, ConflictingHeadersException, Cookie, FileBag, FireCommand, FormRequest, HTTP_RESPONSE_CACHE_CONTROL_DIRECTIVES, HeaderBag, HeaderUtility, HttpContext, HttpRequest, HttpResponse, HttpResponseException, HttpServiceProvider, InputBag, IpUtils, JsonResource, LogRequests, Middleware, ParamBag, Request, Resource, Response, ResponseCodes, ResponseHeaderBag, ServerBag, SuspiciousOperationException, UnexpectedValueException, UploadedFile, statusTexts };
|
|
2259
|
+
export { ApiResource, BadRequestException, ConflictingHeadersException, Cookie, FileBag, FireCommand, FlashDataMiddleware, FormRequest, HeaderBag, HeaderUtility, HttpContext, HttpRequest, HttpResponse, HttpResponseException, HttpServiceProvider, InputBag, IpUtils, JsonResource, JsonResponse, LogRequests, Middleware, ParamBag, Request, Resource, Responsable, Response, ResponseHeaderBag, ServerBag, SuspiciousOperationException, TrustHosts, UnexpectedValueException, UploadedFile };
|