Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • wip-slh-dsa-sha2-128s
  • master-updates
  • release-3.10-fixes
  • getopt-prototype
  • fix-bcrypt-warning
  • refactor-hmac
  • wip-use-alignas
  • trim-sha3-context
  • fix-gitlab-ci
  • check-fat-emulate
  • delete-digest_func-size
  • slh-dsa-shake-128f-nettle
  • slh-dsa-shake-128s-nettle
  • slh-dsa-shake-128s
  • delete-openpgp
  • ppc64-sha512
  • delete-md5-compat
  • cleanup-hmac-tests
  • ppc64-sha256
  • nettle_3.10.2_release_20250626
  • nettle_3.10.1_release_20241230
  • nettle_3.10_release_20240616
  • nettle_3.10rc2
  • nettle_3.10rc1
  • nettle_3.9.1_release_20230601
  • nettle_3.9_release_20230514
  • nettle_3.8.1_release_20220727
  • nettle_3.8_release_20220602
  • nettle_3.7.3_release_20210606
  • nettle_3.7.2_release_20210321
  • nettle_3.7.1_release_20210217
  • nettle_3.7_release_20210104
  • nettle_3.7rc1
  • nettle_3.6_release_20200429
  • nettle_3.6rc3
  • nettle_3.6rc2
  • nettle_3.6rc1
  • nettle_3.5.1_release_20190627
  • nettle_3.5_release_20190626
40 results

pbkdf2-hmac-gosthash94.c

Blame
  • module.pmod 2.09 KiB
    // FIXME! doc bad
    
    //! module Protocols
    //! submodule HTTP
    //! class HeaderParser
    //!	Fast HTTP header parser. 
    
    //! module Protocols
    //! submodule HTTP
    //! method string http_decode_string(string what)
    
    constant HeaderParser=_Roxen.HeaderParser;
    constant http_decode_string=_Roxen.http_decode_string;
    
    //! method mapping(string:string|array(string)) http_decode_urlencoded_query(string query,void|mapping dest)
    //!	Decodes an URL-encoded query into a mapping.
    
    mapping(string:string|array(string))
       http_decode_urlencoded_query(string query,
    				void|mapping dest)
    {
       if (!dest) dest=([]);
    
       foreach (query/"&",string s)
       {
          string i,v;
          if (sscanf(s,"%s=%s",i,v)<2) v=i=http_decode_string(s);
          else i=http_decode_string(i),v=http_decode_string(v);
          if (dest[i]) 
    	 if (arrayp(dest[i])) dest[i]+=({v});
    	 else dest[i]=({dest[i],v});
          else dest[i]=v;
       }
       
       return dest;
    }
    
    
    //! method string filename_to_type(string filename)
    //! method string extension_to_type(string extension)
    //!	Looks up the file extension in a table to return
    //!	a suitable MIME type. The table is located in the
    //!	[...]pike/lib/modules/Protocols.pmod/HTTP.pmod/Server.pmod/extensions.txt
    //!	file.
    
    mapping extensions=0;
    
    string extension_to_type(string extension)
    {
       if (!extensions)
       {
          Stdio.File f=Stdio.FILE(
    	 combine_path(__FILE__,"..","extensions.txt"),"r");
    
          mapping res=([]);
    
          while (array a=f->ngets(1000))
    	 foreach (a,string l)
    	    if (sscanf(l,"%*[ \t]%[^ \t]%*[ \t]%[^ \t]",
    		       string ext,string type)==4 &&
    		ext!="" && ext[0]!='#')
    	       res[ext]=type;
    
          extensions=res;
       }
    
       return extensions[extension] || "application/octet-stream";
    }
    
    string filename_to_type(string filename)
    {
       array v=filename/".";
       if (sizeof(v)<2) return extension_to_type("default");
       return extension_to_type(v[-1]);
    }
    
    //! method string http_date(int time)
    //!	Makes a time notification suitable for the HTTP protocol.
    
    string http_date(int time)
    {
       return Calendar.ISO_UTC.Second(time)->format_http();
    }
    
    
    // server id prefab
    
    constant http_serverid=version()+": HTTP Server module";