Package com.google.common.net

Examples of com.google.common.net.MediaType


            new UpdateCDNContainerOptions().logRetention(false);
      assertEquals(ImmutableList.of("false"), options.buildRequestHeaders().get(CDN_LOG_RETENTION));
   }

   public void testStaticWebsiteDirectoryType() {
      MediaType appDir = MediaType.create("application", "directory");
      UpdateCDNContainerOptions options =
            new UpdateCDNContainerOptions().staticWebsiteDirectoryType(appDir);
      assertEquals(ImmutableList.of(appDir.toString()), options.buildRequestHeaders().get(STATIC_WEB_DIRECTORY_TYPE));
   }
View Full Code Here


            }

            resp.setDateHeader(HttpHeaders.LAST_MODIFIED, asset.getLastModifiedTime());
            resp.setHeader(HttpHeaders.ETAG, asset.getETag());

            MediaType mediaType = DEFAULT_MEDIA_TYPE;
            String mimeType = mimeTypes.getMimeByExtension(req.getRequestURI());

            if (mimeType != null) {
                try {
                    mediaType = MediaType.parse(mimeType);
                    if (defaultCharset != null && mediaType.is(MediaType.ANY_TEXT_TYPE)) {
                        mediaType = mediaType.withCharset(defaultCharset);
                    }
                } catch (IllegalArgumentException ignore) {}
            }

            resp.setContentType(mediaType.type() + "/" + mediaType.subtype());

            if (mediaType.charset().isPresent()) {
                resp.setCharacterEncoding(mediaType.charset().get().toString());
            }

            final ServletOutputStream output = resp.getOutputStream();
            try {
                output.write(asset.getResource());
View Full Code Here

      assertEquals(headers.get(CONTAINER_QUOTA_BYTES), ImmutableList.of("5120"));
      assertEquals(headers.get(CONTAINER_METADATA_PREFIX + "apiname"), ImmutableList.of("swift"));
   }

   public void testStaticWebsiteDirectoryType() {
      MediaType appDir = MediaType.create("application", "directory");
      Multimap<String, String> headers = ImmutableMultimap.of(STATIC_WEB_DIRECTORY_TYPE, appDir.toString());
      UpdateContainerOptions options = new UpdateContainerOptions().headers(headers);
      assertEquals(options.buildRequestHeaders().get(STATIC_WEB_DIRECTORY_TYPE), ImmutableList.of(appDir.toString()));
   }
View Full Code Here

TOP

Related Classes of com.google.common.net.MediaType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.