Package org.w3c.www.mime

Examples of org.w3c.www.mime.MimeType


      if ( strtypes == null )
    return null;
      types = new MimeType[strtypes.length];
      for (int i = 0 ; i < types.length ; i++) {
    try {
        types[i] = new MimeType(strtypes[i]);
    } catch (Exception ex) {
        types[i] = null;
    }
      }
  }
View Full Code Here


  // if there is already a Content-Encoding, skip this
  if (reply.getContentEncoding() != null) {
      return null;
  }
  // Match possible mime types:
  MimeType t[]     = getMimeTypes();
  boolean  matched = false;
  if ( t != null ) {
      for (int i = 0 ; i < t.length ; i++) {
    if ( t[i] == null )
        continue;
View Full Code Here

     * @see JigsawHttpServletResponse#getOutputStream
     * @see JigsawHttpServletResponse#getWriter
     */   
    public void setContentType(String spec) {
  try {
      MimeType type= new MimeType(spec);
      reply.setContentType(type);
      setContentTypeException = null;
  } catch(MimeTypeFormatException ex) {
      //store exception
      setContentTypeException = ex;
View Full Code Here

  }
 
  // content type (charset)
  String charset = org.w3c.www.mime.Utils.getCharset(locale);
  if (charset != null) {
      MimeType contentType = reply.getContentType();
      // override charset
      contentType.setParameter(CHARSET_PARAMETER, charset);
  }
    }
View Full Code Here

    // Dump the request as the body
    // Removed unused headers:
    // FIXME should be something else for chuncked stream
    ByteArrayOutputStream ba = new ByteArrayOutputStream();
    try {
        reply.setContentType(new MimeType("message/http"));
        request.dump(ba);
        reply.setContentLength(ba.size());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
View Full Code Here

  if (array == null)
      return null;
  if (array instanceof String[])
      return (String[]) array;
  else if (array instanceof MimeType[]) {
      MimeType mimes[] = (MimeType[]) array;
      String strArray [] = new String[mimes.length];
      for (int i = 0 ; i < mimes.length ; i++)
    strArray[i] = mimes[i].toString();
      return strArray;
  } else
View Full Code Here

    public Object unpickle (DataInputStream in)
  throws IOException
    {
  int    cnt       = in.readInt() ;
  MimeType mimes[] = new MimeType[cnt] ;
  for (int i = 0 ; i < cnt ; i++) {
      try {
    mimes[i] = new MimeType(in.readUTF()) ;
      } catch (MimeTypeFormatException ex) {
    mimes[i] = null;
      }
  }
  return mimes ;
View Full Code Here

    System.arraycopy(acc, 0, newacc, 1, acc.length);
      } else {
    newacc = new HttpAccept[1];
      }
      try {
    newacc[0] = HttpFactory.makeAccept(new MimeType(param), 1.1);
    request.setAccept(newacc);
      } catch (MimeTypeFormatException ex) {
    // not a valid mime type... maybe something else, do not care
      }
  }
View Full Code Here

    System.arraycopy(acc, 0, newacc, 1, acc.length);
      } else {
    newacc = new HttpAccept[1];
      }
      try {
    newacc[0] = HttpFactory.makeAccept(new MimeType(param), 1.1);
    request.setAccept(newacc);
      } catch (MimeTypeFormatException ex) {
    // not a valid mime type... maybe something else, do not care
      }
  }
View Full Code Here

      error.setContent("partial PUT not supported.");
      throw new HTTPException(error);
  }
  // Check that if some type is provided it doesn't conflict:
  if ( request.hasContentType() ) {
      MimeType rtype = request.getContentType() ;
      MimeType type  = getCommentType() ;
      if ( type == null ) {
    setValue (ATTR_CONTENT_TYPE, rtype) ;
      } else if ( rtype.match (type) < 0 ) {
    if (debug) {
        System.out.println("No match between: ["+
               rtype.toString()+"] and ["+
               type.toString()+"]");
    }
    Reply error = request.makeReply(HTTP.UNSUPPORTED_MEDIA_TYPE) ;
    error.setContent ("<p>Invalid content type: "+type.toString());
    throw new HTTPException (error) ;
      }
  }
  ImageFileResource ifresource = (ImageFileResource) fresource;
  // Write the body back to the file:
View Full Code Here

TOP

Related Classes of org.w3c.www.mime.MimeType

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.