From e044c1b08540448b8e87007b1582759960d72ae3 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 15 May 2016 18:36:49 +0000 Subject: [PATCH] .docs git-svn-id: svn://ultimatepp.org/upp/trunk@9838 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/src.tpp/HttpHeader$en-us.tpp | 135 ++++++++++++++++++++++ uppsrc/Core/src.tpp/HttpRequest$en-us.tpp | 2 +- uppsrc/Core/src.tpp/Inet$en-us.tpp | 124 -------------------- uppsrc/Core/src.tpp/UrlInfo$en-us.tpp | 99 ++++++++++++++++ 4 files changed, 235 insertions(+), 125 deletions(-) create mode 100644 uppsrc/Core/src.tpp/HttpHeader$en-us.tpp create mode 100644 uppsrc/Core/src.tpp/UrlInfo$en-us.tpp diff --git a/uppsrc/Core/src.tpp/HttpHeader$en-us.tpp b/uppsrc/Core/src.tpp/HttpHeader$en-us.tpp new file mode 100644 index 000000000..f9b49410f --- /dev/null +++ b/uppsrc/Core/src.tpp/HttpHeader$en-us.tpp @@ -0,0 +1,135 @@ +topic "HttpHeader"; +[2 $$0,0#00000000000000000000000000000000:Default] +[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] +[l288;2 $$2,2#27521748481378242620020725143825:desc] +[0 $$3,0#96390100711032703541132217272105:end] +[H6;0 $$4,0#05600065144404261032431302351956:begin] +[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item] +[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement] +[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] +[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] +[b42;2 $$9,9#13035079074754324216151401829390:normal] +[{_} +[ {{10000@(113.42.0) [s0;%% [*@7;4 HttpHeader]]}}&] +[s3; &] +[s1;:HttpHeader`:`:struct: [@(0.0.255)3 struct][3 _][*3 HttpHeader]&] +[s2;%% This simple structure simplifies parsing of HTTP request and +response headers. It is also capable of parsing SCGI requests.&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:first`_line: [_^String^ String]_[* first`_line]&] +[s2;%% The first line of request/response `- the content of this +line is different for response and request.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:f3: [_^String^ String]_[* f1, f2, f3]&] +[s2;%% First, second and third part of the first line. Content is +different for response and request.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:fields: [_^VectorMap^ VectorMap]<[_^String^ String], +[_^String^ String]>_[* fields]&] +[s2;%% Http fields as key`-value pairs. Keys are converted to lower`-case. +Note that the same key can be present multiple times.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:cookies: [_^VectorMap^ VectorMap]<[_^String^ String], +[_^HttpCookie^ HttpCookie]>_[* cookies]&] +[s2;%% Set of http response http cookies (filled based on Set`-Cookie +headers during parsing).&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:scgi: [@(0.0.255) bool]_[* scgi]&] +[s2;%% Indicates that this header is a result of parsing scgi.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:operator`[`]`(const char`*`)const: [_^String^ String]_[* operator`[`]]( +[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 id])_[@(0.0.255) const]&] +[s2;%% Returns the first http header field with key [%-*@3 id] (must +be lower`-case) or empty string if such field is not present.&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:GetCookie`(const char`*`)const: [_^String^ String]_[* GetCookie]([@(0.0.255) c +onst]_[@(0.0.255) char]_`*[*@3 id])_[@(0.0.255) const]&] +[s2;%% Returns the value of first cookie of response (set by Set`-Cookie) +with name [%-*@3 id].&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:Response`(String`&`,int`&`,String`&`)const: [@(0.0.255) bool]_[* Respo +nse]([_^String^ String][@(0.0.255) `&]_[*@3 protocol], [@(0.0.255) int`&]_[*@3 code], +[_^String^ String][@(0.0.255) `&]_[*@3 reason])_[@(0.0.255) const]&] +[s2;%% Returns first line fields of http response.&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:Request`(String`&`,String`&`,String`&`)const: [@(0.0.255) bool]_[* Req +uest]([_^String^ String][@(0.0.255) `&]_[*@3 method], [_^String^ String][@(0.0.255) `&]_[*@3 u +ri], [_^String^ String][@(0.0.255) `&]_[*@3 version])_[@(0.0.255) const]&] +[s2;%% Returns first line fields of http request.&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:GetProtocol`(`)const: [_^String^ String]_[* GetProtocol]()_[@(0.0.255) c +onst]&] +[s2;%% Returns the protocol part of of the first line response.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:GetCode`(`)const: [@(0.0.255) int]_[* GetCode]()_[@(0.0.255) const]&] +[s2;%% Returns the return code part of the first line of response.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:GetReason`(`)const: [_^String^ String]_[* GetReason]()_[@(0.0.255) const +]&] +[s2;%% Returns the reason part of the first line of response.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:GetMethod`(`)const: [_^String^ String]_[* GetMethod]()_[@(0.0.255) const +]&] +[s2;%% Returns the method part of the first line of request.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:GetURI`(`)const: [_^String^ String]_[* GetURI]()_[@(0.0.255) const]&] +[s2;%% Returns the URI part of the first line of request.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:GetVersion`(`)const: [_^String^ String]_[* GetVersion]()_[@(0.0.255) con +st]&] +[s2;%% Returns the version part of the first line of request.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:GetContentLength`(`)const: [_^int64^ int64]_[* GetContentLength]()_[@(0.0.255) c +onst]&] +[s2;%% Returns the content length as specified in header or 0 if +not specified or header not yet loaded.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:Clear`(`): [@(0.0.255) void]_[* Clear]()&] +[s2;%% Clears data.&] +[s3; &] +[s4; &] +[s5;:HttpHeader`:`:ParseAdd`(const String`&`): [@(0.0.255) bool]_[* ParseAdd]([@(0.0.255) c +onst]_[_^String^ String][@(0.0.255) `&]_[*@3 hdrs])&] +[s2;%% Parses the header (all lines of header) into [* first`_line +]and [* fields].&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:Parse`(const String`&`): [@(0.0.255) bool]_[* Parse]([@(0.0.255) const]_ +[_^String^ String][@(0.0.255) `&]_[*@3 hdrs])&] +[s2;%% Calls Clear and parses the header (all lines of header) into +[* first`_line ]and [* fields].&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:ParseSCGI`(const String`&`): [@(0.0.255) bool]_[* ParseSCGI]([@(0.0.255) c +onst]_[_^String^ String][@(0.0.255) `&]_[*@3 scgi`_hdr])&] +[s2;%% Parse SCGI header, resulting state is as if the header parsed +was normal HTTP.&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:Read`(TcpSocket`&`): [@(0.0.255) bool]_[* Read]([_^TcpSocket^ TcpSocket][@(0.0.255) `& +]_[*@3 socket])&] +[s2;%% Reads the header from [%-*@3 socket] and parses it. Method detects +SCGI requests based on first character of request `- if it is +a digit, SCGI is assumed and the header is parsed as SCGI.&] +[s3;%% &] +[s4; &] +[s5;:HttpHeader`:`:HttpHeader`(`): [* HttpHeader]()&] +[s2;%% Default constructor.&] +[s0;%% ]] \ No newline at end of file diff --git a/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp b/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp index e8d67f6d7..a6b52d836 100644 --- a/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp +++ b/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp @@ -16,7 +16,7 @@ topic "HttpRequest"; ][*@3;3 TcpSocket]&] [s2;%% This class performs synchronous or asynchronous HTTP requests.&] [s3;%% &] -[ {{10000F(128)G(128)@1 [s0;%% [* Public Method List]]}}&] +[ {{10000F(128)G(128)@1 [s0;%% [* Public Member List]]}}&] [s3; &] [s5;:HttpRequest`:`:WhenContent: [_^Callback2^ Callback2]<[@(0.0.255) const]_[@(0.0.255) vo id]_`*, [@(0.0.255) int]>_[* WhenContent]&] diff --git a/uppsrc/Core/src.tpp/Inet$en-us.tpp b/uppsrc/Core/src.tpp/Inet$en-us.tpp index 85aabd3c2..a354ac25e 100644 --- a/uppsrc/Core/src.tpp/Inet$en-us.tpp +++ b/uppsrc/Core/src.tpp/Inet$en-us.tpp @@ -132,128 +132,4 @@ server`". If [%-*@3 gzip] is true, function adds `"content`-encoding: gzip`" header, but does NOT actually zip the content (that is up to caller).&] [s3; &] -[s0; &] -[ {{10000@(113.42.0) [s0;%% [*@7;4 HttpHeader]]}}&] -[s3; &] -[s1;:HttpHeader`:`:struct: [@(0.0.255)3 struct][3 _][*3 HttpHeader]&] -[s2;%% This simple structure simplifies parsing of http request and -response headers. It is also capable of parsing SCGI requests.&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:first`_line: [_^String^ String]_[* first`_line]&] -[s2;%% The first line of request/response `- the content of this -line is different for response and request.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:f3: [_^String^ String]_[* f1, f2, f3]&] -[s2;%% First, second and third part of the first line. Content is -different for response and request.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:fields: [_^VectorMap^ VectorMap]<[_^String^ String], -[_^String^ String]>_[* fields]&] -[s2;%% Http fields as key`-value pairs. Keys are converted to lower`-case. -Note that the same key can be present multiple times.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:cookies: [_^VectorMap^ VectorMap]<[_^String^ String], -[_^HttpCookie^ HttpCookie]>_[* cookies]&] -[s2;%% Set of http response http cookies (filled based on Set`-Cookie -headers during parsing).&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:scgi: [@(0.0.255) bool]_[* scgi]&] -[s2;%% Indicates that this header is a result of parsing scgi.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:operator`[`]`(const char`*`)const: [_^String^ String]_[* operator`[`]]( -[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 id])_[@(0.0.255) const]&] -[s2;%% Returns the first http header field with key [%-*@3 id] (must -be lower`-case) or empty string if such field is not present.&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:GetCookie`(const char`*`)const: [_^String^ String]_[* GetCookie]([@(0.0.255) c -onst]_[@(0.0.255) char]_`*[*@3 id])_[@(0.0.255) const]&] -[s2;%% Returns the value of first cookie of response (set by Set`-Cookie) -with name [%-*@3 id].&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:Response`(String`&`,int`&`,String`&`)const: [@(0.0.255) bool]_[* Respo -nse]([_^String^ String][@(0.0.255) `&]_[*@3 protocol], [@(0.0.255) int`&]_[*@3 code], -[_^String^ String][@(0.0.255) `&]_[*@3 reason])_[@(0.0.255) const]&] -[s2;%% Returns first line fields of http response.&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:Request`(String`&`,String`&`,String`&`)const: [@(0.0.255) bool]_[* Req -uest]([_^String^ String][@(0.0.255) `&]_[*@3 method], [_^String^ String][@(0.0.255) `&]_[*@3 u -ri], [_^String^ String][@(0.0.255) `&]_[*@3 version])_[@(0.0.255) const]&] -[s2;%% Returns first line fields of http request.&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:GetProtocol`(`)const: [_^String^ String]_[* GetProtocol]()_[@(0.0.255) c -onst]&] -[s2;%% Returns the protocol part of of the first line response.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:GetCode`(`)const: [@(0.0.255) int]_[* GetCode]()_[@(0.0.255) const]&] -[s2;%% Returns the return code part of the first line of response.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:GetReason`(`)const: [_^String^ String]_[* GetReason]()_[@(0.0.255) const -]&] -[s2;%% Returns the reason part of the first line of response.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:GetMethod`(`)const: [_^String^ String]_[* GetMethod]()_[@(0.0.255) const -]&] -[s2;%% Returns the method part of the first line of request.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:GetURI`(`)const: [_^String^ String]_[* GetURI]()_[@(0.0.255) const]&] -[s2;%% Returns the URI part of the first line of request.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:GetVersion`(`)const: [_^String^ String]_[* GetVersion]()_[@(0.0.255) con -st]&] -[s2;%% Returns the version part of the first line of request.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:GetContentLength`(`)const: [_^int64^ int64]_[* GetContentLength]()_[@(0.0.255) c -onst]&] -[s2;%% Returns the content length as specified in header or 0 if -not specified or header not yet loaded.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:Clear`(`): [@(0.0.255) void]_[* Clear]()&] -[s2;%% Clears data.&] -[s3; &] -[s4; &] -[s5;:HttpHeader`:`:ParseAdd`(const String`&`): [@(0.0.255) bool]_[* ParseAdd]([@(0.0.255) c -onst]_[_^String^ String][@(0.0.255) `&]_[*@3 hdrs])&] -[s2;%% Parses the header (all lines of header) into [* first`_line -]and [* fields].&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:Parse`(const String`&`): [@(0.0.255) bool]_[* Parse]([@(0.0.255) const]_ -[_^String^ String][@(0.0.255) `&]_[*@3 hdrs])&] -[s2;%% Calls Clear and parses the header (all lines of header) into -[* first`_line ]and [* fields].&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:ParseSCGI`(const String`&`): [@(0.0.255) bool]_[* ParseSCGI]([@(0.0.255) c -onst]_[_^String^ String][@(0.0.255) `&]_[*@3 scgi`_hdr])&] -[s2;%% Parse SCGI header, resulting state is as if the header parsed -was normal HTTP.&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:Read`(TcpSocket`&`): [@(0.0.255) bool]_[* Read]([_^TcpSocket^ TcpSocket][@(0.0.255) `& -]_[*@3 socket])&] -[s2;%% Reads the header from [%-*@3 socket] and parses it. Method detects -SCGI requests based on first character of request `- if it is -a digit, SCGI is assumed and the header is parsed as SCGI.&] -[s3;%% &] -[s4; &] -[s5;:HttpHeader`:`:HttpHeader`(`): [* HttpHeader]()&] -[s2;%% Default constructor.&] -[s3; &] [s0;%% ]] \ No newline at end of file diff --git a/uppsrc/Core/src.tpp/UrlInfo$en-us.tpp b/uppsrc/Core/src.tpp/UrlInfo$en-us.tpp new file mode 100644 index 000000000..cffa41645 --- /dev/null +++ b/uppsrc/Core/src.tpp/UrlInfo$en-us.tpp @@ -0,0 +1,99 @@ +topic "UrlInfo"; +[2 $$0,0#00000000000000000000000000000000:Default] +[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] +[l288;2 $$2,2#27521748481378242620020725143825:desc] +[0 $$3,0#96390100711032703541132217272105:end] +[H6;0 $$4,0#05600065144404261032431302351956:begin] +[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item] +[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement] +[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] +[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] +[b42;2 $$9,9#13035079074754324216151401829390:normal] +[{_} +[ {{10000@(113.42.0) [s0;%% [*@7;4 UrlInfo]]}}&] +[s0; &] +[s1;:Upp`:`:UrlInfo`:`:struct: [@(0.0.255)3 struct][3 _][*3 UrlInfo]&] +[s2;%% Parses URL into parts and provides easy access to query parameters.&] +[s0;i448;a25;kKO9;:noref:@(0.0.255) &] +[ {{10000F(128)G(128)@1 [s0;%% [* Public Member List]]}}&] +[s0;%% &] +[s0;%% Example values are based on parsing URL&] +[s0;%% &] +[s0;%% [@3 http://username:password`@hostname:9090/path?arg`=value`&aarg`[`]`=item1`&aarg`[ +`]`=item2#anchor]&] +[s0;%% &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:url: [_^Upp`:`:String^ String]_[* url]&] +[s2;%% Original url.&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:scheme: [_^Upp`:`:String^ String]_[* scheme]&] +[s2;%% URL scheme: [@3 http]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:host: [_^Upp`:`:String^ String]_[* host]&] +[s2;%% Host: [@3 hostname]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:port: [_^Upp`:`:String^ String]_[* port]&] +[s2;%% Port: [@3 9090]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:user: [_^Upp`:`:String^ String]_[* username]&] +[s2;%% Authentication username: [@3 username]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:password: [_^Upp`:`:String^ String]_[* password]&] +[s2;%% Authentication password: [@3 password]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:path: [_^Upp`:`:String^ String]_[* path]&] +[s2;%% Path: [@3 /path]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:query: [_^Upp`:`:String^ String]_[* query]&] +[s2;%% Query: [@3 arg`=value`&aarg`[`]`=item1`&aarg`[`]`=item2]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:fragment: [_^Upp`:`:String^ String]_[* fragment]&] +[s2;%% Fragment: [@3 anchor]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:parameters: [_^Upp`:`:VectorMap^ VectorMap]<[_^Upp`:`:String^ Stri +ng], [_^Upp`:`:String^ String]>_[* parameters]&] +[s2;%% Scalar query parameters: [@(0.0.255) `{`"][@3 arg][@(0.0.255) `": +`"][@3 value][@(0.0.255) `"`}]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:array`_parameters: [_^Upp`:`:VectorMap^ VectorMap]<[_^Upp`:`:String^ S +tring], [_^Upp`:`:Vector^ Vector]<[_^Upp`:`:String^ String]>>_[* array`_parameters]&] +[s2;%% Array query parameters: [@(0.0.255) `{`"][@3 aarg][@(0.0.255) `": +`[`"][@3 item1][@(0.0.255) `", `"][@3 item2][@(0.0.255) `"`]`}]&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:Clear`(`): [@(0.0.255) void]_[* Clear]()&] +[s2;%% Clears the URL to initial states (everything is empty).&] +[s3; &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:Parse`(const Upp`:`:String`&`): [@(0.0.255) void]_[* Parse]([@(0.0.255) c +onst]_[_^Upp`:`:String^ String][@(0.0.255) `&]_[*@3 url])&] +[s2;%% Parses [%-*@3 url].&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:operator`[`]`(const char`*`)const: [_^Upp`:`:String^ String]_[* op +erator`[`]]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 id])_[@(0.0.255) const]&] +[s2;%% Returns value of scalar parameter or empty string if not present.&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:GetArray`(const char`*`)const: [@(0.0.255) const]_[_^Upp`:`:Vector^ V +ector]<[_^Upp`:`:String^ String]>`&_[* GetArray]([@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 i +d])_[@(0.0.255) const]&] +[s2;%% Returns reference to array parameter or reference to empty +array if not present.&] +[s3;%% &] +[s4; &] +[s5;:Upp`:`:UrlInfo`:`:UrlInfo`(const Upp`:`:String`&`): [* UrlInfo]([@(0.0.255) const]_[_^Upp`:`:String^ S +tring][@(0.0.255) `&]_[*@3 url])&] +[s2;%% Constructs UrlInfo by parsing [%-*@3 url].&] +[s3;%% &] +[s0;%% ]] \ No newline at end of file