Differences From Artifact [4079ebb727]:
- File
src/OFHTTPClient.m
— part of check-in
[a0fd103a0b]
at
2021-03-07 02:36:04
on branch trunk
— Style change: Allow more than 1 argument per line
This is only migrating some places, others will be migrated as they are
touched. (user: js, size: 30144) [annotate] [blame] [check-ins using]
To Artifact [02e9faa541]:
- File src/OFHTTPClient.m — part of check-in [1b82d3bf4f] at 2021-03-07 20:25:21 on branch trunk — *.m: Fold methods into one line where it fits (user: js, size: 30068) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
714 715 716 717 718 719 720 | } URLPort = URL.port; if (URLPort != nil) port = URLPort.unsignedShortValue; sock.delegate = self; | | < | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | } URLPort = URL.port; if (URLPort != nil) port = URLPort.unsignedShortValue; sock.delegate = self; [sock asyncConnectToHost: URL.host port: port]; } @catch (id e) { [self raiseException: e]; } } @end @implementation OFHTTPClientRequestBodyStream |
︙ | ︙ | |||
796 797 798 799 800 801 802 | errNo: 0]; if (_chunked) [_socket writeFormat: @"%zX\r\n", length]; else if (length > _toWrite) length = (size_t)_toWrite; | | < | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | errNo: 0]; if (_chunked) [_socket writeFormat: @"%zX\r\n", length]; else if (length > _toWrite) length = (size_t)_toWrite; ret = [_socket writeBuffer: buffer length: length]; if (_chunked) [_socket writeString: @"\r\n"]; if (ret > length) @throw [OFOutOfRangeException exception]; if (!_chunked) { |
︙ | ︙ | |||
901 902 903 904 905 906 907 | _toRead = (long long)toRead; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidServerReplyException exception]; } } } | | < | < | < < | < | < | < < | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | _toRead = (long long)toRead; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidServerReplyException exception]; } } } - (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length { if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; if (!_hasContentLength && !_chunked) return [_socket readIntoBuffer: buffer length: length]; if (_socket.atEndOfStream) @throw [OFTruncatedDataException exception]; /* Content-Length */ if (!_chunked) { size_t ret; if (length > (unsigned long long)_toRead) length = (size_t)_toRead; ret = [_socket readIntoBuffer: buffer length: length]; if (ret > length) @throw [OFOutOfRangeException exception]; _toRead -= ret; if (_toRead == 0) _atEndOfStream = true; return ret; } /* Chunked */ if (_toRead == -2) { char tmp[2]; switch ([_socket readIntoBuffer: tmp length: 2]) { case 2: _toRead++; if (tmp[1] != '\n') @throw [OFInvalidServerReplyException exception]; case 1: _toRead++; if (tmp[0] != '\r') @throw [OFInvalidServerReplyException exception]; } if (_setAtEndOfStream && _toRead == 0) _atEndOfStream = true; return 0; } else if (_toRead == -1) { char tmp; if ([_socket readIntoBuffer: &tmp length: 1] == 1) { _toRead++; if (tmp != '\n') @throw [OFInvalidServerReplyException exception]; } if (_setAtEndOfStream && _toRead == 0) _atEndOfStream = true; return 0; } else if (_toRead > 0) { if (length > (unsigned long long)_toRead) length = (size_t)_toRead; length = [_socket readIntoBuffer: buffer length: length]; _toRead -= length; if (_toRead == 0) _toRead = -2; return length; } else { void *pool = objc_autoreleasePoolPush(); OFString *line; |
︙ | ︙ | |||
1111 1112 1113 1114 1115 1116 1117 | [super dealloc]; } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { | | < < < | 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 | [super dealloc]; } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { [_client asyncPerformRequest: request redirects: redirects]; [[OFRunLoop currentRunLoop] run]; return _response; } - (void)client: (OFHTTPClient *)client didPerformRequest: (OFHTTPRequest *)request response: (OFHTTPResponse *)response exception: (id)exception |
︙ | ︙ | |||
1217 1218 1219 1220 1221 1222 1223 | [self close]; [super dealloc]; } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request { | | < | 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 | [self close]; [super dealloc]; } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request { return [self performRequest: request redirects: REDIRECTS_DEFAULT]; } - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { void *pool = objc_autoreleasePoolPush(); OFHTTPClientSyncPerformer *syncPerformer = |
︙ | ︙ | |||
1240 1241 1242 1243 1244 1245 1246 | objc_autoreleasePoolPop(pool); return [response autorelease]; } - (void)asyncPerformRequest: (OFHTTPRequest *)request { | | < | 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | objc_autoreleasePoolPop(pool); return [response autorelease]; } - (void)asyncPerformRequest: (OFHTTPRequest *)request { [self asyncPerformRequest: request redirects: REDIRECTS_DEFAULT]; } - (void)asyncPerformRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { void *pool = objc_autoreleasePoolPush(); OFURL *URL = request.URL; |
︙ | ︙ |