Examples of MediaType


Examples of com.eclipsesource.restfuse.MediaType

      }
    }
  }

  private void addContentType( HttpTest call, InternalRequest request ) {
    MediaType contentType = call.type();
    if( contentType != null ) {
      request.setContentType( contentType.getMimeType() );
    }
  }
View Full Code Here

Examples of com.facebook.presto.jdbc.internal.guava.net.MediaType

    {
        try {
            String contentType = response.getHeader(CONTENT_TYPE);

            if (contentType != null) {
                MediaType mediaType = MediaType.parse(contentType);
                return new StringResponse(
                        response.getStatusCode(),
                        response.getStatusMessage(),
                        response.getHeaders(),
                        new String(ByteStreams.toByteArray(response.getInputStream()), mediaType.charset().or(Charsets.UTF_8)));
            }

            return new StringResponse(
                    response.getStatusCode(),
                    response.getStatusMessage(),
View Full Code Here

Examples of com.google.common.net.MediaType

                if (!expectedResponseCodes.contains(response.getStatusCode())) {
                    throw new APIException(request, response);
                }

                // TODO: once we switch to jackson we can take the media type into account automatically
                final MediaType responseContentType;
                if (response.getContentType() == null) {
                    responseContentType = MediaType.JSON_UTF_8;
                } else {
                    responseContentType = MediaType.parse(response.getContentType());
                }

                if (!responseContentType.is(mediaType.withoutParameters())) {
                    LOG.warn("We said we'd accept {} but got {} back, let's see how that's going to work out...", mediaType, responseContentType);
                }
                if (responseClass.equals(String.class)) {
                    return responseClass.cast(response.getResponseBody("UTF-8"));
                }

                if (expectedResponseCodes.contains(response.getStatusCode())
                        || (response.getStatusCode() >= 200 && response.getStatusCode() < 300)) {
                    T result;
                    try {
                        if (response.getResponseBody().isEmpty()) {
                            return null;
                        }

                        if (responseContentType.is(MediaType.JSON_UTF_8.withoutParameters())) {
                            result = deserializeJson(response, responseClass);
                        } else {
                            LOG.error("Don't know how to deserialize objects with content in {}, expected {}, failing.", responseContentType, mediaType);
                            throw new APIException(request, response);
                        }
View Full Code Here

Examples of com.ramforth.webserver.http.MediaType

        parseMediaType();
    }

    private void parseMediaType() {
        this.mediaType = new MediaType();

        String[] splitRawValue = rawValue.split(";");

        if (splitRawValue.length > 0) {
            mediaType.setType(splitRawValue[0]);
View Full Code Here

Examples of com.semagia.atomico.MediaType

                lastModification);
        applyAuthorInfo(config, feed);
        for (ICollectionInfo info: storage.getCollectionInfos(config.getCollectionSortOrder())) {
            feed.addEntry(info, LinkUtils.linkToCollection(baseURI, info));
        }
        final MediaType mediaType = getFeedMediaType(feedMediaTypes);
        final IOutputAwareFeedHandler handler = makeFeedHandler(mediaType);
        return new FeedWritable(new OverviewFeedWriter(feed, handler), mediaType);
    }
View Full Code Here

Examples of freenet.support.MediaType

            option = optionList.addChild("li");
            NodeL10n.getBase().addL10nSubstitution(option, "FProxyToadlet.openAsThawIndex", new String[] { "link" }, new HTMLNode[] { HTMLNode.link("/plugins/plugins.ThawIndexBrowser.ThawIndexBrowser/?key=" + key.toString()).addChild("b") });
          }
          option = optionList.addChild("li");
          // FIXME: is this safe? See bug #131
          MediaType textMediaType = new MediaType("text/plain");
          textMediaType.setParameter("charset", (e.getExpectedMimeType() != null) ? MediaType.getCharsetRobust(e.getExpectedMimeType()) : null);
          NodeL10n.getBase().addL10nSubstitution(option, "FProxyToadlet.openAsText", new String[] { "link" }, new HTMLNode[] { HTMLNode.link(getLink(key, textMediaType.toString(), maxSize, null, false, maxRetries, overrideSize)) });
          option = optionList.addChild("li");
          NodeL10n.getBase().addL10nSubstitution(option, "FProxyToadlet.openForceDisk", new String[] { "link" }, new HTMLNode[] { HTMLNode.link(getLink(key, mime, maxSize, null, true, maxRetries, overrideSize)) });
          if(!(mime.equals("application/octet-stream") || mime.equals("application/x-msdownload") || !DefaultMIMETypes.isPlausibleMIMEType(mime))) {
            option = optionList.addChild("li");
            NodeL10n.getBase().addL10nSubstitution(option, "FProxyToadlet.openForce", new String[] { "link", "mime" }, new HTMLNode[] { HTMLNode.link(getLink(key, mime, maxSize, getForceValue(key, now), false, maxRetries, overrideSize)), HTMLNode.text(HTMLEncoder.encode(mime))});
View Full Code Here

Examples of javax.ws.rs.core.MediaType

    * @param request
    * @return
    */
   protected ResourceInvoker match(String httpMethod, HttpRequest request)
   {
      MediaType contentType = request.getHttpHeaders().getMediaType();

      List<MediaType> oldaccepts = request.getHttpHeaders().getAcceptableMediaTypes();
      List<WeightedMediaType> accepts = new ArrayList<WeightedMediaType>();
      for (MediaType accept : oldaccepts) accepts.add(WeightedMediaType.parse(accept));

View Full Code Here

Examples of javax.ws.rs.core.MediaType

      }
      else if (request.getBody() != null)
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();

         MediaType bodyContentType = request.getBodyContentType();
         request.getHeadersAsObjects().add(HttpHeaders.CONTENT_TYPE, bodyContentType.toString());

         request.writeRequestBody(request.getHeadersAsObjects(), baos);
         // commit headers after byte array is complete.
         commitHeaders(request, mockHttpRequest);
         mockHttpRequest.content(baos.toByteArray());
View Full Code Here

Examples of javax.ws.rs.core.MediaType

      String contentType = (String) response.getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);

      byte[] cached = ReadFromStream.readFromStream(1024, response.getStreamFactory().getInputStream());
      response.getStreamFactory().performReleaseConnection();

      MediaType mediaType = MediaType.valueOf(contentType);
      final BrowserCache.Entry entry = cache.put(request.getUri(), mediaType,
              response.getHeaders(), cached, expires, etag, lastModified);

      response.setStreamFactory(new CachedStreamFactory(entry));
View Full Code Here

Examples of javax.ws.rs.core.MediaType

         }
         Collections.sort(waccepts);
         List<MediaType> accepts = new ArrayList<MediaType>();
         for (WeightedMediaType accept : waccepts)
         {
            accepts.add(new MediaType(accept.getType(), accept.getSubtype(), accept.getParameters()));
         }
         for (MediaType accept : accepts)
         {
            entry = cache.get(uri, accept);
            if (entry != null) return entry;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.