Code Monkey home page Code Monkey logo

jqhttprequest's Introduction

JQHttpRequest

前言

JQHttpRequest:目前二次封装网络库支持四种请求:GET、POST、PUT、DELETE较常见的请求,HEAD/PATH/COPY/OPTIONS/LINK/LOCK等不常用的后续会根据需求调整,本库支持数据缓存、缓存超时设置、请求超时设置等;支持cer证书验证等;

更新记录

  • 0.0.5 新增文件上传, 文件下载, 设置请求头等
  • 0.0.4 新增取消全部请求
  • 0.0.3 新增CER证书验证
  • 0.0.2 新增EGOCache缓存, 新增四种缓存方式
  • 0.0.1 发布第一版本 0.0.1

Installation

From CocoaPods

pod  "JQHttpRequest"

Manually

  • Drag all source files under floder JQHttpRequest to your project.

Usage

///Test
    [[JQBaseRequest sharedManager].setRequest(COLLECTION_LIST).RequestType(JQRequestMethodGET).Cachetype(JQBaseRequestReloadIgnoringLocalCacheData).cerName(nil).timeoutInterval(30).CachTime(60).Parameters(nil) startRequestWithSuccess:^(NSURLSessionDataTask *task, id responseObject) {
        
    } progress:^(NSProgress *progress) {
        
    /* NSProgress 不能为nil,因为AFN的默认参数是 _Nonnull 修饰的!*/
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"%@",error);
    }];

  • 参数说明:
setRequest:  请求url
RequestType: 
             请求类型:
             JQRequestMethodGET = 0,
             JQRequestMethodPOST,
             JQRequestMethodPUT,
             JQRequestMethodDELETE 目前支持四种,会持续更新;
-------------------------------------------------------------------------
Cachetype: 缓存类型:
JQBaseRequestReturnCacheDataThenLoad = 0,  ///< 有缓存就先返回缓存,同步请求数据
JQBaseRequestReloadIgnoringLocalCacheData, ///< 忽略缓存,重新请求
JQBaseRequestReturnCacheDataElseLoad,      ///< 有缓存就用缓存,没有缓存就重新请求(用于数据不变时)
JQBaseRequestReturnCacheDataDontLoad,      ///< 有缓存就用缓存,没有缓存就不发请求,当做请求出错处理(用于离线模式)

cerName: cer证书名称,设置则开启验证,默认不开启,若设置请确保名称正确,否则导致crash;

timeoutInterval: 请求超时设置 默认20s
CachTime:        设置缓存时间 默认时间一天
Parameters:      参数设置 字典传输

          
  • startRequestWithSuccess: 请求函数,提供三个,如下:
/**
 *  发送请求
 *
 *  @param Success  成功的回调
 *  @param Progress 进度的回调
 *  @param Fail     请求错误的回调
 */
- (void)startRequestWithSuccess:(JQResponseSuccess)Success progress:(JQProgress)Progress failure:(JQResponseFail)Fail;
/**
 *  上传文件
 *
 *  @param Success  成功的回调
 *  @param Progress 进度的回调
 *  @param Fail     请求错误的
 */
- (void)uploadfileWithSuccess:(JQResponseSuccess)Success progress:(JQProgress)Progress failure:(JQResponseFail)Fail;
/**
 *  下载文件
 *
 *  @param Success  成功的回调
 *  @param Progress 进度的回调
 *  @param Fail     请求错误的
 *  @return 返回NSURLSessionDownloadTask实例,可用于暂停继续,暂停调用suspend方法,重新开启下载调用resume方法
 */
- (NSURLSessionDownloadTask *)downloadWithSuccess:(JQFileSuccess)Success progress:(JQProgress)Progress failure:(JQResponseFail)Fail;

Note

progress:^(NSProgress *progress)不能为nil,因为AFN的默认参数是 _Nonnull 修饰的!

  • 正确姿势:

Other

JQTumblrHud-高仿Tumblr App 加载指示器hud

JQScrollNumberLabel:仿tumblr热度滚动数字条数

TumblrLikeAnimView-仿Tumblr点赞动画效果

JQMenuPopView-仿Tumblr弹出视图发音频、视频、图片、文字的视图

Star

CSDN博客

iOS开发者交流群:①群:446310206 ②群:426087546 喜欢就❤️❤️❤️star一下吧!

Love is every every every star! Your support is my renewed motivation!

License

This code is distributed under the terms and conditions of the MIT license.

jqhttprequest's People

Contributors

xiaohange avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jqhttprequest's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.