Check-in [afc2bb0ecf]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:[HTTP.BAS] - Implement two functions to Set and Get HTTP Cookie values.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:afc2bb0ecf399196f821577274ea03621adcd3e0
User & Date: Administrador 2016-10-06 02:50:13
Context
2016-10-06
02:54
[HTTP.BAS] - Implement the SetContentType function. check-in: e8a8d61f52 user: Administrador tags: trunk
02:50
[HTTP.BAS] - Implement two functions to Set and Get HTTP Cookie values. check-in: afc2bb0ecf user: Administrador tags: trunk
02:44
[HTTP.BAS] - Add a file to implement the HTTP protocol functions and initialize the header. check-in: ebbd8290d2 user: Administrador tags: trunk
Changes

Changes to root/core/http.bas.

1
2








































'################################# http.bas ####################################
'HTTP 1.1 headers functions and initialization










































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
'################################# http.bas ####################################
'HTTP 1.1 headers functions and initialization

FUNCTION SetCookie$(cookieName$, cookieValue$, domain$, path$, expiresDate$, maxAgeTime, secure, httpOnly)
  DIM strOutput$
  'Add standard parameters
  strOutput$ = "Set-Cookie:" + CHR$(32) + cookieName$ + CHR$(61) + cookieValue$
  IF domain$ <> "" THEN
    strOutput$ = strOutput$ + CHR$(59) + CHR$(32) + "Domain=" + domain$
  END IF
  IF path$ <> "" THEN
    strOutput$ = strOutput$ + CHR$(59) + CHR$(32) + "Path=" + path$
  END IF
  IF expiresDate$ <> "" THEN
    'TODO: validate HTTP date format Wdy, DD Mon YYYY HH:MM:SS GMT
    strOutput$ = strOutput$ + CHR$(59) + CHR$(32) + "Expires=" + expiresDate$
  END IF
  IF maxAgeTime > 0 THEN
    strOutput$ = strOutput$ + CHR$(59) + CHR$(32) + "Max-Age=" + LTRIM$(STR$(maxAgeTime))
  END IF
  IF secure = 1 THEN
    strOutput$ = strOutput$ + CHR$(59) + CHR$(32) + "Secure"
  END IF
  IF httpOnly = 1 THEN
    strOutput$ = strOutput$ + CHR$(59) + CHR$(32) + "HttpOnly"
  END IF
  'Add the line feed
  strOutput$ = strOutput$ + CHR$(13) + CHR$(10)
  SetCookie$ = strOutput$
  strOutput$ = ""
END FUNCTION

FUNCTION GetCookie$(cookieName$)
  DIM RawCookieStr$
  RawCookieStr$ = ENVIRON$("HTTP_COOKIE")
  IF cookieName$ <> "" THEN
    GetCookie$ = SplitVar$(RawCookieStr$, cookieName$, CHR$(59))
  ELSE
    GetCookie$ = RawCookieStr$
  END IF
  RawCookieStr$ = ""
END FUNCTION