Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 5 of 5 for setExtensionType (0.17 sec)

  1. src/mime/type_unix.go

    			continue
    		}
    		if _, ok := mimeTypes.Load(extension); ok {
    			// We've already seen this extension.
    			// The file is in weight order, so we keep
    			// the first entry that we see.
    			continue
    		}
    
    		setExtensionType(extension, fields[1])
    	}
    	if err := scanner.Err(); err != nil {
    		panic(err)
    	}
    	return nil
    }
    
    func loadMimeFile(filename string) {
    	f, err := os.Open(filename)
    	if err != nil {
    		return
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 11 20:56:32 UTC 2023
    - 3K bytes
    - Viewed (0)
  2. src/mime/type_plan9.go

    	for scanner.Scan() {
    		fields := strings.Fields(scanner.Text())
    		if len(fields) <= 2 || fields[0][0] != '.' {
    			continue
    		}
    		if fields[1] == "-" || fields[2] == "-" {
    			continue
    		}
    		setExtensionType(fields[0], fields[1]+"/"+fields[2])
    	}
    	if err := scanner.Err(); err != nil {
    		panic(err)
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sun May 15 19:56:08 UTC 2016
    - 1K bytes
    - Viewed (0)
  3. src/mime/type.go

    func AddExtensionType(ext, typ string) error {
    	if !strings.HasPrefix(ext, ".") {
    		return fmt.Errorf("mime: extension %q missing leading dot", ext)
    	}
    	once.Do(initMime)
    	return setExtensionType(ext, typ)
    }
    
    func setExtensionType(extension, mimeType string) error {
    	justType, param, err := ParseMediaType(mimeType)
    	if err != nil {
    		return err
    	}
    	if strings.HasPrefix(mimeType, "text/") && param["charset"] == "" {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 5K bytes
    - Viewed (0)
  4. src/mime/type_windows.go

    		// defaults, this problem is common enough that we
    		// handle it here by ignoring that registry setting.
    		if name == ".js" && (v == "text/plain" || v == "text/plain; charset=utf-8") {
    			continue
    		}
    
    		setExtensionType(name, v)
    	}
    }
    
    func initMimeForTests() map[string]string {
    	return map[string]string{
    		".PnG": "image/png",
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sat May 28 20:07:28 UTC 2022
    - 1.2K bytes
    - Viewed (0)
  5. src/mime/type_test.go

    }
    
    func clearMimeTypes() {
    	setMimeTypes(map[string]string{}, map[string]string{})
    }
    
    func setType(ext, typ string) {
    	if !strings.HasPrefix(ext, ".") {
    		panic("missing leading dot")
    	}
    	if err := setExtensionType(ext, typ); err != nil {
    		panic("bad test data: " + err.Error())
    	}
    }
    
    func TestTypeByExtension(t *testing.T) {
    	once = sync.Once{}
    	// initMimeForTests returns the platform-specific extension =>
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Aug 08 21:09:03 UTC 2022
    - 4.9K bytes
    - Viewed (0)
Back to top