mxcl/OMGHTTPURLRQ là dự án Objective-C với 337 sao. Vital extensions to NSURLRequest that Apple left out for some reason.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
You can then pass these to an NSURLConnection or NSURLSession.
multipart/form-data
OMG! Constructing multipart/form-data for POST requests is complicated, let us do it for you:
OMGMultipartFormData *multipartFormData = [OMGMultipartFormData new];
NSData *data1 = [NSData dataWithContentsOfFile:@"myimage1.png"];
[multipartFormData addFile:data1 parameterName:@"file1" filename:@"myimage1.png" contentType:@"image/png"];
// Ideally you would not want to re-encode the PNG, but often it is
// tricky to avoid it.
UIImage *image2 = [UIImage imageNamed:@"image2"];
NSData *data2 = UIImagePNGRepresentation(image2);
[multipartFormData addFile:data2 parameterName:@"file2" filename:@"myimage2.png" contentType:@"image/png"];
// SUPER Ideally you would not want to re-encode the JPEG as the process
// is lossy. If your image comes from the AssetLibrary you *CAN* get the
// original `NSData`. See stackoverflow.com.
UIImage *image3 = [UIImage imageNamed:@"image3"];
NSData *data3 = UIImageJPEGRepresentation(image3);
[multipartFormData addFile:data3 parameterName:@"file2" filename:@"myimage3.jpeg" contentType:@"image/jpeg"];
NSMutableURLRequest *rq = [OMGHTTPURLRQ POST:url:multipartFormData];
Now feed rq to [NSURLConnection sendSynchronousRequest:returningResponse:error:.
Configuring an NSURLSessionUploadTask
If you need to use NSURLSession’s uploadTask: but you have become frustrated because your endpoint expects a multipart/form-data POST request and NSURLSession sends the data raw, use this:
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/mxcl/OMGHTTPURLRQ là nguồn chính thức.
mxcl/OMGHTTPURLRQ có phải mã nguồn mở không?
Có — mxcl/OMGHTTPURLRQ phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/mxcl/OMGHTTPURLRQ.
mxcl/OMGHTTPURLRQ là gì?
mxcl/OMGHTTPURLRQ (mxcl/OMGHTTPURLRQ) là dự án Objective-C trên GitHub. Theo mô tả gốc: Vital extensions to NSURLRequest that Apple left out for some reason.
Đọc đầy đủ README ở tab phía trên.
OMGHTTPURLRQ có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về OMGHTTPURLRQ.