zoukankan      html  css  js  c++  java
  • Get&Post请求和MIMEType

    1.GET请求:

     NSString *urlStr = [NSStringstringWithFormat:@"http://192.168.3.251/~apple/itcast/login.php?username=%@&password=%@",_userName.text,_password.text];

        

        NSURL *url = [NSURL URLWithString:urlStr];

        

        NSURLRequest *request = [NSURLRequestrequestWithURL:url];

        

        NSURLConnection *connection = [NSURLConnectionconnectionWithRequest:request delegate:self];

        

        [connection start];

    2.POST请求

     NSString *urlStr = [NSStringstringWithFormat:@"http://192.168.3.251/~apple/itcast/login.php"];

        NSURL *url = [NSURL URLWithString:urlStr];

        

        NSMutableURLRequest *request = [NSMutableURLRequestrequestWithURL:url];

        

        request.HTTPMethod = @"POST";

        

        NSString *bodyStr = [NSStringstringWithFormat:@"username=%@&password=%@",_userName.text,_password.text];

        request.HTTPBody = [bodyStr dataUsingEncoding:NSUTF8StringEncoding];

        

        NSURLConnection *connection = [NSURLConnectionconnectionWithRequest:request delegate:self];

        

        [connection start];

    3.同步请求,和异步请求

    //异步请求

      [NSURLConnection sendAsynchronousRequest:<#(NSURLRequest *)#> queue:<#(NSOperationQueue *)#> completionHandler:<#^(NSURLResponse *response, NSData *data, NSError *connectionError)handler#>];

    //同步请求

        [NSURLConnection sendSynchronousRequest:<#(NSURLRequest *)#> returningResponse:<#(NSURLResponse *__autoreleasing *)#> error:<#(NSError *__autoreleasing *)#>];

    4.数据安全

    MD5

    5.MiMEType

    .txt--------->ext/plain

    .pdf-------->application/pdf

    .docx ---------->application/vnd.openxmlformats-officedocument.wordprocessingml.document

    .html--------->text/html

  • 相关阅读:
    AngularJS ui-router (嵌套路由)
    解决Can't connect to MySQL server on 'localhost' (10048)
    PHP获取一年有几周以及每周开始日期和结束日期
    MySQL(八)之DML
    MySQL(七)MySQL常用函数
    MySQL(六)之MySQL常用操作符
    MySQL(五)之DDL(数据定义语言)与六大约束
    MySQL(四)之MySQL数据类型
    MySQL(三)之SQL语句分类、基本操作、三大范式
    linux命令详解之netstat
  • 原文地址:https://www.cnblogs.com/yinqiang/p/3496254.html
Copyright © 2011-2022 走看看