Write part header

@param name
@param filename
@param contentType
@return this request
@throws java.io.IOException
13227
protected OkRequest<T> writePartHeader(final String name,
                                           final String filename, final String contentType) throws IOException {
        final StringBuilder partBuffer = new StringBuilder();
        partBuffer.append("form-data; name=\"").append(name);
        if (filename != null) {
            partBuffer.append("\"; filename=\"").append(filename);
        }
        partBuffer.append('"');
        partHeader("Content-Disposition", partBuffer.toString());
        if (contentType != null) {
            partHeader(HEADER_CONTENT_TYPE, contentType);
        }
        return send(CRLF);
    }
1215634
public BoxFile.Info uploadFile(InputStream fileContent, String name) {
        FileUploadParams uploadInfo = new FileUploadParams()
                .setContent(fileContent)
                .setName(name);
        return this.uploadFile(uploadInfo);
    }
1328806
public void startPart(String contentType) throws IOException {
        if (inPart)
            out.write(__CRLF);
        inPart = true;
        out.write(__DASHDASH);
        out.write(boundaryBytes);
        out.write(__CRLF);
        if (contentType != null)
            out.write(("Content-Type: " + contentType).getBytes(StandardCharsets.ISO_8859_1));
        out.write(__CRLF);
        out.write(__CRLF);
    }
632955
public static HeaderTypes create(final String name) {
        if (name == null) {
            throw new IllegalArgumentException("header name may not be null");
        }
        String type = name.trim().toLowerCase(Locale.ENGLISH);
        if (type.length() == 0) {
            throw new IllegalArgumentException("header name may not be empty");
        }
        return new HeaderTypes(name);
    }
1300674
public final B contentType(CharSequence contentType) {
        requireNonNull(contentType, "contentType");
        autoDetectedContentType(false);
        return setHeader(HttpHeaderNames.CONTENT_TYPE, contentType);
    }
1280412
public static void setContentTypeHeader(HttpResponse response, File file) {
		String mimeType = MimeTypes.getMimeTypeForFileName(file.getName());
		String mimeFinal = mimeType != null ? mimeType : MimeTypes.getDefaultMimeType();
		response.headers().set(CONTENT_TYPE, mimeFinal);
	}
1236567
protected void writeFile(String basename, T content,
			Function2<? super File, ? super String, ? extends File> outputDirectoryFilter) {
		// Create the file.
		// Encode
		final byte[] bytes = content.toString().getBytes(Charset.forName(getCodeConfig().getEncoding()));
		writeFile(basename, bytes, outputDirectoryFilter);
	}
988465
private void writeDocument(String fullDocument, String filename) {
		// create output file handle
		File outFile = new File(mOutputDir, filename+".xml"); 
		
		BufferedWriter bw = null;
		try {
			// create a buffered writer for the output file
			bw = new BufferedWriter(new FileWriter(outFile));
			bw.append(fullDocument);
			
		} catch (IOException e) { // something went wrong with the bufferedwriter
			e.printStackTrace();
			Logger.printError(component, "File "+outFile.getAbsolutePath()+" could not be written.");
		} finally { // clean up for the bufferedwriter
			try {
				bw.close();
			} catch(IOException e) {
				e.printStackTrace();
				Logger.printError(component, "File "+outFile.getAbsolutePath()+" could not be closed.");
			}
		}
	}
102142
public Response andContentType(String contentType) {
        Objects.requireNonNull(contentType, Required.CONTENT_TYPE.toString());
        this.contentType = contentType;
        this.headers.put(Header.CONTENT_TYPE.toHttpString(), contentType);

        return this;
    }
506130
public static void initFileSendHeader(HttpServletResponse res, String filename, String contentType) {

        filename = getEncodingFileName(filename);
        if (contentType != null) {
            res.setContentType(contentType);
        } else {
            res.setContentType("applicaiton/download;charset=utf-8");
        }
        res.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\";");
        res.setHeader("Content-Transfer-Encoding", "binary");
        res.setHeader("file-name", filename);

    }
12855
public void writeToFile(StringBuffer content, String filename, String encoding) throws NoSuchPathException, IOException{
		try {
			OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(filename), encoding);
			writer.write(content.toString(), 0, content.length());
			writer.flush();
			writer.close();
		} catch (FileNotFoundException e) {
			throw new NoSuchPathException(e);
		}
	}
661714
public KieServerHttpRequest contentType(final String contentType, final String charset ) {
        if( charset != null && charset.length() > 0 ) {
            final String separator = "; " + PARAM_CHARSET + '=';
            return header(CONTENT_TYPE, contentType + separator + charset);
        } else
            return header(CONTENT_TYPE, contentType);
    }
225279
public static void write(HttpServletResponse response, InputStream in, String contentType) {
		response.setContentType(contentType);
		write(response, in);
	}
126205
public void startPart(String contentType)
         throws IOException
    {
        if (inPart)
            out.write(__CRLF);
        inPart=true;
        out.write(__DASHDASH);
        out.write(boundaryBytes);
        out.write(__CRLF);
        out.write(("Content-Type: "+contentType).getBytes(StringUtil.__ISO_8859_1));
        out.write(__CRLF);
        out.write(__CRLF);
    }
588358
public function addFile(string $name, string $filePath, string $contentType = 'application/octet-stream') {
        $fileName = \basename($filePath);
        $this->fields[] = [$name, new FileBody($filePath), $contentType, $fileName];
        $this->isMultipart = true;
        $this->resetCache();
    }
1267534
protected void writeHeader() throws IOException {
		this.tmpOutput.write(HEADER_KEY.getBytes());
		this.tmpOutput.write(new byte[]{MAJOR_SPEC_NUMBER, MINOR_SPEC_NUMBER});
		this.tmpOutput.write(new byte[] {0, 0, 0, 0});
	}
1282874
@Override
    public RequestContent getRequestContent(HttpServletRequest request,
                                            HttpHeaders headers)
        throws Exception {
        RequestContent rContent = null;

        // See if the request is a multi-part file upload request
        if (ServletFileUpload.isMultipartContent(request)) {

            // Create a new file upload handler
            ServletFileUpload upload = new ServletFileUpload();

            // Parse the request, use the first available File item
            FileItemIterator iter = upload.getItemIterator(request);
            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                if (!item.isFormField()) {
                    rContent = new RequestContent();
                    rContent.contentStream = item.openStream();
                    rContent.mimeType = item.getContentType();

                    FileItemHeaders itemHeaders = item.getHeaders();
                    if (itemHeaders != null) {
                        String contentLength =
                            itemHeaders.getHeader("Content-Length");
                        if (contentLength != null) {
                            rContent.size = Long.parseLong(contentLength);
                        }
                    }

                    break;
                }
            }
        } else {
            // If the content stream was not found as a multipart,
            // try to use the stream from the request directly
            rContent = new RequestContent();
            rContent.contentStream = request.getInputStream();
            if (request.getContentLength() >= 0) {
                rContent.size = request.getContentLength();
            }
        }

        // Attempt to set the mime type and size if not already set
        if (rContent != null) {
            if (rContent.mimeType == null) {
                MediaType mediaType = headers.getMediaType();
                if (mediaType != null) {
                    rContent.mimeType = mediaType.toString();
                }
            }

            if (rContent.size == 0) {
                List<String> lengthHeaders =
                    headers.getRequestHeader("Content-Length");
                if (lengthHeaders != null && lengthHeaders.size() > 0) {
                    rContent.size = Long.parseLong(lengthHeaders.get(0));
                }
            }
        }

        return rContent;
    }