summary refs log tree commit diff stats
path: root/tests/fragmentation
Commit message (Expand)AuthorAgeFilesLines
* tests: disable flaky tests for now; closes #9421Araq2018-10-182-1/+2
* fixes #8509 disable 4GB allocating test on windows that crashed appveyor (#8510)Timothee Cour2018-08-021-3/+6
* disable flaky fragmenation test for AppVeyorAraq2018-03-191-0/+1
* make the allocator take a special path for allocations bigger than 2GB; fixes...Araq2018-02-271-0/+4
* tfragment_gc test: make more robustAraq2018-02-131-1/+1
* make tfragment_gc more robust for AppveyorAraq2018-01-101-1/+1
* another attempt to make the fragmentation test more robust for WindowsAndreas Rumpf2018-01-091-1/+1
* make tfragment_gc more robustAraq2017-12-121-1/+4
* change tfragment_gc test for appveyorAndreas Rumpf2017-12-081-1/+1
* lets see what appveyor reports as the used memoryAndreas Rumpf2017-12-071-1/+4
* enable fragmentation testsAraq2017-12-072-10/+26
* cleanup todo.txtAraq2017-12-073-0/+7664
ld } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#
#
#            Nim's Runtime Library
#        (c) Copyright 2012 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

## This module implements helper procs for parsing Cookies.

import strtabs, times

proc parseCookies*(s: string): StringTableRef = 
  ## parses cookies into a string table.
  result = newStringTable(modeCaseInsensitive)
  var i = 0
  while true:
    while s[i] == ' ' or s[i] == '\t': inc(i)
    var keystart = i
    while s[i] != '=' and s[i] != '\0': inc(i)
    var keyend = i-1
    if s[i] == '\0': break
    inc(i) # skip '='
    var valstart = i
    while s[i] != ';' and s[i] != '\0': inc(i)
    result[substr(s, keystart, keyend)] = substr(s, valstart, i-1)
    if s[i] == '\0': break
    inc(i) # skip ';'

proc setCookie*(key, value: string, domain = "", path = "",
                expires = "", noName = false,
                secure = false, httpOnly = false): string =
  ## Creates a command in the format of 
  ## ``Set-Cookie: key=value; Domain=...; ...``
  result = ""
  if not noName: result.add("Set-Cookie: ")
  result.add key & "=" & value
  if domain != "": result.add("; Domain=" & domain)
  if path != "": result.add("; Path=" & path)
  if expires != "": result.add("; Expires=" & expires)
  if secure: result.add("; secure")
  if httpOnly: result.add("; HttpOnly")

proc setCookie*(key, value: string, expires: TimeInfo,
                domain = "", path = "", noName = false,
                secure = false, httpOnly = false): string =
  ## Creates a command in the format of 
  ## ``Set-Cookie: key=value; Domain=...; ...``
  ##
  ## **Note:** UTC is assumed as the timezone for ``expires``.  
  return setCookie(key, value, domain, path,
                   format(expires, "ddd',' dd MMM yyyy HH:mm:ss 'UTC'"),
                   noname, secure, httpOnly)

when isMainModule:
  var tim = Time(int(getTime()) + 76 * (60 * 60 * 24))

  echo(setCookie("test", "value", tim.getGMTime()))
  
  echo parseCookies("uid=1; kp=2")