New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cn.microanswer:HttpUtil

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cn.microanswer:HttpUtil

This is a network request tool class. Base on the okhttp project. All the methods in this tool class are synchronous. Asynchronous support is not part of the network request category. You may need to handle the asynchronous problem on your own.

Source
mavenMaven Central
Version
1.1.0
Version published
Maintainers
1
Source

HttpUtil 网络请求工具类

网络请求工具,一个方法完成网络请求。本工具是依赖于 okhttp 进行的再一次封装,使每次网络请求代码更精简。欢迎大家提交issues或反馈bug及建议到 Microanswer邮箱

#注意:本工具类里所有方法均为同步方法。

简介

支持:\

  • GET请求\
  • 下载文件\
  • POST表单格式数据\
  • POST JSON数据\
  • 上传文件\
  • 以上所有都支持传递自定义header,参数。\
  • 自动日志记录。(日志规则自动使用你的项目的配置规则)\

安装

maven 项目

<dependency>
    <groupId>cn.microanswer</groupId>
    <artifactId>HttpUtil</artifactId>
    <version>1.1.0</version>
</dependency>

gradle 项目

compile group: 'cn.microanswer', name: 'HttpUtil', version: '1.1.0'

下载 jar 包

点击下载

开始使用

// 使用 Get 请求
String responseString = HttpUtil.get("http://microanswer.cn");
// 下载文件到 指定目录
File downloadedFile = HttpUtil.download("http://microanswer.cn", new File("D:/"));
// 提交 POST 表单请求
HttpUtil.postFormUrlEncode("http://microanswer.cn/", null);
// 提交 POST JSON请求
HttpUtil.postApplicationJson("http://microanswer.cn/api/common.php", (JSONObject) null);
// 上传文件到指定url
HttpUtil.upload("http://microanswer.cn", new File("D:/test.mp3"));
// 如果只有一个文件, 则该文件的表单name是:file

// 多个文件
HttpUtil.upload("http://microanswer.cn", new File("D:/test.mp3"), new File("D:/test1.mp3"), new File("D:/test2.mp3"));
// 如果有多个文件,则第一个文件的表单name是:file,往后依次:file1, file2,file3,...
// 更复杂的请求可通过:
HttpUtil.post(url, contentType, bodyBytes, headers); 
// 关闭日志记录
HttpUtil.LOG = false;

网站

Microanswer

FAQs

Package last updated on 29 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts