Skip to content
Snippets Groups Projects
Select Git revision
  • 41f057477037be860bf8bd640cb6b586f8e055a2
  • master default
  • dbck-q-n-d-link
  • foutput-text_stat-override
  • generations
  • text-stat-sha256
  • use-nettle
  • import-nettle
  • refactor-cached_get_text
  • refactor-cached_get_text-part-2
  • add-text_store
  • introduce-generation_position
  • remove-reclamation
  • dbfile-temp-filenames
  • sstrdup
  • dbfile_open_read-check-magic
  • adns_dist
  • liboop_dist
  • search
  • isc
  • dbdbckmultiplechoice
  • last.cvs.revision
  • 2.1.2
  • 2.1.1
  • 2.1.0
  • adns_1_0
  • liboop_0_9
  • 2.0.7
  • search_bp
  • 2.0.6
  • 2.0.5
  • isc_1_01
  • Protocol-A-10.4
  • 2.0.4
  • 2.0.3
  • 2.0.2
  • 2.0.1
  • 2.0.0
  • isc_1_00
  • isc_merge_1999_05_01
  • isc_merge_1999_04_21
41 results

send-async.c

Blame
  • module.pmod 1.82 KiB
    #pike __REAL_VERSION__
    
    //! Fast HTTP header parser.
    constant HeaderParser=_Roxen.HeaderParser;
    
    //!
    constant http_decode_string=_Roxen.http_decode_string;
    
    
    //! 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(replace(i,"+"," ")),v=http_decode_string(replace(v,"+"," "));
          if (dest[i]) 
    	 if (arrayp(dest[i])) dest[i]+=({v});
    	 else dest[i]=({dest[i],v});
          else dest[i]=v;
       }
       
       return dest;
    }
    
    
    
    //! Looks up the file extension in a table to return a suitable MIME
    //! type.
    string extension_to_type(string extension)
    {
       return MIME.ext_to_media_type(extension) || "application/octet-stream";
    }
    
    //! Looks up the file extension in a table to return a suitable MIME
    //! type.
    string filename_to_type(string filename)
    {
       array v=filename/".";
       if (sizeof(v)<2) return extension_to_type("default");
       return extension_to_type(v[-1]);
    }
    
    //!	Makes a time notification suitable for the HTTP protocol.
    //! @param time
    //!  The time in seconds since the 00:00:00 UTC, January 1, 1970
    //! @returns
    //!  The date in the HTTP standard date format.
    //!  Example : Thu, 03 Aug 2000 05:40:39 GMT
    string http_date(int time)
    {
       return Calendar.ISO_UTC.Second(time)->format_http();
    }
    
    //! 	Decode a HTTP date to seconds since 1970 (UTC)
    //! @returns
    //!	zero (UNDEFINED) if the given string isn't a HTTP date
    int http_decode_date(string data)
    {
       Calendar.ISO_UTC.Second s=
          Calendar.ISO_UTC.parse("%e, %D %M %Y %h:%m:%s GMT",data);
       if (!s) return UNDEFINED;
       return s->unix_time();
    }