| 52 | } |
| 53 | |
| 54 | func TestLoadURLFailure(t *testing.T) { |
| 55 | contentTypes := []string{ |
| 56 | "application/pdf", |
| 57 | "application/json", |
| 58 | "application/tlsrpt+gzip", |
| 59 | "application/vnd.3gpp.pic-bw-small", |
| 60 | "application/vnd.collabio.xodocuments.document-template", |
| 61 | "application/vnd.ctc-posml", |
| 62 | "application/vnd.gov.sk.e-form+zip", |
| 63 | "audio/mp4", |
| 64 | "audio/vnd.sealedmedia.softseal.mpeg", |
| 65 | "image/png", |
| 66 | "image/vnd.adobe.photoshop", |
| 67 | "message/example", |
| 68 | "message/vnd.wfa.wsc", |
| 69 | "model/vnd.usdz+zip", |
| 70 | "model/vnd.valve.source.compiled-map", |
| 71 | "multipart/signed", |
| 72 | "text/css", |
| 73 | "text/html", |
| 74 | "video/quicktime", |
| 75 | "video/JPEG", |
| 76 | } |
| 77 | |
| 78 | for _, contentType := range contentTypes { |
| 79 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 80 | w.Header().Set("Content-Type", contentType) |
| 81 | })) |
| 82 | defer server.Close() |
| 83 | _, err := LoadURL(server.URL) |
| 84 | if err != nil && err.Error() == fmt.Sprintf("invalid XML document(%s)", contentType) { |
| 85 | return |
| 86 | } |
| 87 | |
| 88 | t.Fatalf("Want invalid XML document(%s), got %v", contentType, err) |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | func TestDefaultNamespace_1(t *testing.T) { |
| 93 | s := `<?xml version="1.0" encoding="UTF-8" standalone="no"?> |