File: index.md

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (126 lines) | stat: -rw-r--r-- 2,590 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
HTTP Library
===========

The package [stormname:http] contains an early version of a HTTP library. The library contains both
a basic [HTTP client](md:Client) and a [HTTP server](md:Server).


The library was originally developed by: Christoffer Lundell, Erik Bäck Lindström, Filip Wojtulewicz, Fabian Pranke, Joel Gustafsson, Martin Weman


Basic Types
-----------

The library is centered around the types [stormname:http.Request] and [stormname:http.Response],
that represent a HTTP request and a HTTP response respectively.

The `Request` type has the following members:

```stormdoc
@http.Request
- .method
- .version
- .path
- .headers
- .cookies
- .immediateResponse
```

The `Response` type has the following members:

```stormdoc
@http.Response
- .version
- .status
- .header(*)
- .cookies
- .contentType(*)
- .__init()
- .__init(core.Str)
- .__init(core.Str, Status)
```

In addition, there are three enumerations that encode central concepts within HTTP:

[stormname:http.Version]
```bs
enum Version {
    HTTP_0_9,
    HTTP_1_0,
    HTTP_1_1
}
```

[stormname:http.Status] encodes HTTP status codes:
```bs
enum Status {
    none = 0,

    //Informational 1xx
    Continue = 100,
    Switching_Protocol = 101,

    //Successful 2xx
    OK = 200,
    Created = 201,
    Accepted = 202,
    Non_Authorative_Information = 203,
    No_Content = 204,
    Reset_Content = 205,
    Partial_Content = 206,

    //Redirectional 3xx
    Multiple_Choice = 300,
    Moved_Permanently = 301,
    Found = 302,
    See_Other = 303,
    Not_Modified = 304,
    Use_Proxy = 305,
    //306 (Unused), not used anymore
    Temporary_Redirect = 307,

    //Client Error 4xx
    Bad_Request = 400,
    Unauthorized = 401,
    Payment_Required = 402,
    Forbidden = 403,
    Not_Found = 404,
    Method_Not_Allowed = 405,
    Not_Acceptable = 406,
    Proxy_Authentication_Required = 407,
    Request_Timeout = 408,
    Conflict = 409,
    Gone = 410,
    Length_Required = 411,
    Prediction_Failed = 412,
    Request_Entity_Too_Large = 413,
    Request_URI_Too_Long = 414,
    Unsupported_Media_Type = 415,
    Request_Range_Not_Satisfiable = 416,
    Expectation_Failed = 417,

    //Server Error 5xx
    Internal_Server_Error = 500,
    Not_Implemented = 501,
    Bad_Gateway = 502,
    Service_Unavailable = 503,
    Gateway_Timeout = 504,
    HTTP_Version_Not_Supported = 505
}
```

[stormname:http.Method] encodes the different HTTP methods that exist:
```bs
enum Method {
    none,
    OPTIONS,
    GET,
    HEAD,
    POST,
    PUT,
    DELETE,
    TRACE,
    CONNECT,
    BAD_METHOD
}
```