Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: src/DefaultWebRequestCurl.cpp

Issue 29391775: Issue 5013 - Improve some const-correctness (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Left Patch Set: Created March 22, 2017, 3:37 p.m.
Right Patch Set: Removed GetType() const-ness change Created March 23, 2017, 12:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/FilterEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); 137 curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
138 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 138 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
139 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ReceiveData); 139 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ReceiveData);
140 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &responseText); 140 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &responseText);
141 // Request compressed data. Using any supported aglorithm 141 // Request compressed data. Using any supported aglorithm
142 curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""); 142 curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "");
143 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, ReceiveHeader); 143 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, ReceiveHeader);
144 curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headerData); 144 curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headerData);
145 145
146 struct curl_slist* headerList = 0; 146 struct curl_slist* headerList = 0;
147 for (auto it = requestHeaders.cbegin(); it != requestHeaders.cend(); ++it) 147 for (const auto& header : requestHeaders)
148 { 148 {
149 headerList = curl_slist_append(headerList, (it->first + ": " + it->second) .c_str()); 149 headerList = curl_slist_append(headerList, (header.first + ": " + header.s econd).c_str());
150 } 150 }
151 if (headerList) 151 if (headerList)
152 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerList); 152 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerList);
153 153
154 result.status = ConvertErrorCode(curl_easy_perform(curl)); 154 result.status = ConvertErrorCode(curl_easy_perform(curl));
155 result.responseStatus = headerData.status; 155 result.responseStatus = headerData.status;
156 result.responseText = responseText.str(); 156 result.responseText = responseText.str();
157 for (auto it = headerData.headers.cbegin(); it != headerData.headers.cend(); ++it) 157 for (const auto& header : headerData.headers)
158 { 158 {
159 // Parse header name and value out of something like "Foo: bar" 159 // Parse header name and value out of something like "Foo: bar"
160 std::string header = *it;
161 size_t colonPos = header.find(':'); 160 size_t colonPos = header.find(':');
162 if (colonPos != std::string::npos) 161 if (colonPos != std::string::npos)
163 { 162 {
164 size_t nameStart = 0; 163 size_t nameStart = 0;
165 size_t nameEnd = colonPos; 164 size_t nameEnd = colonPos;
166 while (nameEnd > nameStart && isspace(header[nameEnd - 1])) 165 while (nameEnd > nameStart && isspace(header[nameEnd - 1]))
167 nameEnd--; 166 nameEnd--;
168 167
169 size_t valueStart = colonPos + 1; 168 size_t valueStart = colonPos + 1;
170 while (valueStart < header.length() && isspace(header[valueStart])) 169 while (valueStart < header.length() && isspace(header[valueStart]))
(...skipping 10 matching lines...) Expand all
181 } 180 }
182 } 181 }
183 } 182 }
184 183
185 if (headerList) 184 if (headerList)
186 curl_slist_free_all(headerList); 185 curl_slist_free_all(headerList);
187 curl_easy_cleanup(curl); 186 curl_easy_cleanup(curl);
188 } 187 }
189 return result; 188 return result;
190 } 189 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld