Performs POST to supplied url of a file as binary data.
@param url url to post to.
@param result result containing request, its response will be filled.
@param headers headers to add.
@param file file containing binary data to post.
161951
public void doHttpFilePost(String url, HttpResponse result, Map<String, Object> headers, File file) {
        httpClient.post(url, result, headers, file);
    }
673879
public void write(Map<String, Object> params) throws IOException {
		LineWriter writer = new LineWriter(this.out);
		try {
			for (Map.Entry<String, Object> param: params.entrySet()) {
				writer.println(MULTIPART_BOUNDARY_SEPARATOR);

				if (param.getValue() instanceof BinaryAttachment) {
					BinaryAttachment ba = (BinaryAttachment)param.getValue();
					writer.println("Content-Disposition: form-data; name=\"" + StringUtils.urlEncode(param.getKey()) + "\"; filename=\""
							+ StringUtils.urlEncode(ba.filename) + "\"");
					writer.println("Content-Type: " + ba.contentType);
					writer.println("Content-Transfer-Encoding: binary");
					writer.println();
					writer.flush();
					// Now output the binary part to the raw stream
					int read;
					byte[] chunk = new byte[8192];
					while ((read = ba.data.read(chunk)) > 0)
						this.out.write(chunk, 0, read);
				} else {
					writer.println("Content-Disposition: form-data; name=\"" + StringUtils.urlEncode(param.getKey()) + "\"");
					writer.println();
					writer.println(StringUtils.urlEncode(param.getValue().toString()));
				}
			}

			writer.println(MULTIPART_BOUNDARY_END);
			writer.flush();
		} finally {
			writer.close();
		}
	}
1326449
public void renderSoapHeader(final Map<String, String> context, final Result result) {
		renderSoapHeader(RESULT_MARSHALLER, context, result);
	}
1123544
function(file, callback) {
        var number = arguments[2] || 0;
        var location = url.parse(file);
        var protocol = location.protocol === 'http:' ? http : https;
        var timeoutEventId;
        var that = this;
        var REDIRECTION_MAX = 3;

        var done = function(errors, data) {
            clearTimeout(timeoutEventId);
            callback(errors, data);
        }


        var request = protocol.request({
                method: 'GET',
                host: location.host,
                hostname: location.hostname,
                path: location.path,
                port: location.port,
                headers: this.adapter.resourceRequestHeaders(file)
            }, function(res) {

                var encoding = res.headers['content-encoding'];
                var type = res.headers['content-type'];
                var statusCode = res.statusCode;
                var errors = null;

                if (/3\d\d/.test(statusCode) && res.headers.location && number < REDIRECTION_MAX) {
                    clearTimeout(timeoutEventId);
                    var file = res.headers.location;
                    number++;
                    that.loadRemoteFile(file, callback, number);
                    return;
                } else if (!/2\d\d/.test(statusCode)) {
                    errors = new Error(res.statusMessage);
                }

                if (type.indexOf('text/') !== 0) {
                    errors = new Error('only supports `text/*` resources');
                }


                if (errors) {
                    done(errors);
                } else {

                    var buffer = new Buffer([]);


                    if (encoding === 'undefined') {
                        res.setEncoding('utf-8');
                    }


                    res.on('data', function(chunk) {
                        buffer = Buffer.concat([buffer, chunk]);
                    });

                    res.on('end', function() {

                        if (encoding === 'gzip') {

                            zlib.unzip(buffer, function(errors, buffer) {
                                if (errors) {
                                    done(errors);
                                } else {
                                    done(null, buffer);
                                }
                            });

                        } else if (encoding == 'deflate') {

                            zlib.inflate(buffer, function(errors, decoded) {
                                if (errors) {
                                    done(errors);
                                } else {
                                    done(null, decoded);
                                }
                            });

                        } else {
                            done(null, buffer);
                        }

                    });

                }

            })
            .on('error', done)
            .on('timeout', function(errors) {
                request.abort();
                done(errors);
            });


        timeoutEventId = setTimeout(function() {
            request.emit('timeout', new Error('have been timeout'));
        }, this.adapter.resourceTimeout);


        request.end();

    }
80338
public static String post(String url,
                              Map<String, String> header,
                              Map<String, String> params) throws IOException {

        HttpURLConnection httpUrlConn = httpUrlConn(url);
        httpUrlConn.setDoOutput(true);
        httpUrlConn.setRequestMethod(Constant.RequestMethodPost);
        // header
        if (header != null) {
            header(header, httpUrlConn);
        }

        httpUrlConn.connect();

        // out
        if (params != null) {
            PrintWriter pw = new PrintWriter(httpUrlConn.getOutputStream());
            String param = Utils.getUrlParamsByMap(params);
            pw.print(param);
            pw.flush();
            pw.close();
        }

        return readIO(httpUrlConn);
    }
174756
public void doHttpPost(String url, HttpResponse result, Map<String, Object> headers, String contentType) {
        httpClient.post(url, result, headers, contentType);
    }
158893
public static void uploadAsync(String url, String key, File file, HttpCallback callback) {
        uploadAsync(url, null, callback, new IOParam(key, file));
    }
609719
function(url, outFile, cb, persist, headers) {
    this.file.save(
      outFile,
      request.get(
        {
          url : url,
          headers : headers
        }
      ),
      persist,
      cb
    );
  }
81620
def post(self, url, data, headers={}):
        
        response = self._run_method('POST', url, data=data, headers=headers)
        return self._handle_response(url, response)
250795
protected BaseResponse executePost(String url, String json, File file) {
        BaseResponse response;
        BeanUtil.requireNonNull(url, "url is null");
        List<File> files = null;
        if (null != file) {
            files = CollectionUtil.newArrayList(file);
        }
        //需要传token
        String postUrl = url.replace("#", config.getAccessToken());
        response = NetWorkCenter.post(postUrl, json, files);
        return response;
    }
277352
public static synchronized void multipart(String url, HttpConsumer<MultipartExchange> endpoint) {
        multipart(Methods.POST, url, endpoint, -1);
    }
963674
private void writeMultipartDataRequest(HttpURLConnection connection, Request request, File file) {
        try (DataOutputStream wr = new DataOutputStream(connection.getOutputStream())) {
            wr.writeBytes(NEWLINE);
            if (request != null && request.getJsonPayload() != null) {
                wr.writeBytes(NEWLINE + "--" + BOUNDARY + NEWLINE);
                wr.writeBytes("Content-Disposition: form-data; name=\"data\"");
                wr.writeBytes(NEWLINE + NEWLINE);
                wr.writeBytes(request.getJsonPayload().toString());
            }
            if (request != null && request.getMultipartData() != null) {
                for (String param : request.getMultipartData().keySet()) {
                    wr.writeBytes(NEWLINE + "--" + BOUNDARY + NEWLINE);
                    wr.writeBytes("Content-Disposition: form-data; name=\"" + param + "\"");
                    wr.writeBytes(NEWLINE + NEWLINE);
                    wr.writeBytes(request.getMultipartData().get(param).toString());
                }
            }
            if (file != null) {
                if (!file.exists()) {
                    log.error("Unable to upload file with http call, as file can't be found: " + file.getName());
                } else {
                    wr.writeBytes(NEWLINE + "--" + BOUNDARY + NEWLINE);
                    wr.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"");
                    wr.writeBytes(NEWLINE);
                    wr.writeBytes("Content-Type: " + Files.probeContentType(file.toPath()));
                    wr.writeBytes(NEWLINE + NEWLINE);
                    byte[] bytes = Files.readAllBytes(file.toPath());
                    wr.write(bytes);
                }
            }
            wr.writeBytes(NEWLINE + "--" + BOUNDARY + "--" + NEWLINE);
            wr.flush();
        } catch (IOException e) {
            log.error(e);
        }
    }
648362
public static void downloadAsync(String url, String file, HttpCallback<File> callback) {
        downloadAsync(url, file, null, callback, new StrParam[0]);
    }
340541
@Override
  public void readHeader(RandomAccessFile file) throws IOException {
    file.seek(0);
    if(file.readInt() != FILE_VERSION) {
      throw new RuntimeException("File " + file + " is not a PersistentPageFile or wrong version!");
    }

    this.pageSize = file.readInt();
  }
1039213
def _post_request(self, url, headers, data=None):
        

        # Grab file from data.
        files = None
        for field, value in data:
            if field == 'file':
                if isinstance(value, dict):
                    files = value
                else:
                    files = {'file': value}
                break

        # Remove file entry from data.
        data[:] = [tup for tup in data if tup[0] != 'file']

        return self._session.post(url, headers=headers, data=data, files=files)
636547
public void doGet(String url, HttpResponse response, Map<String, Object> headers, boolean followRedirect) {
        response.setRequest(url);
        httpClient.get(url, response, headers, followRedirect);
    }
573661
public void doHttpPut(String url, String templateName, Object model, HttpResponse result) {
        doHttpPut(url, templateName, model, result, null, XmlHttpResponse.CONTENT_TYPE_XML_TEXT_UTF8);
    }