|
1 | 1 | using FRED.Core.Data;
|
2 | 2 | using FRED.Core.Fritzbox.Networking.HTTP;
|
3 | 3 | using System;
|
| 4 | +using System.Net.Http; |
4 | 5 |
|
5 | 6 | namespace FRED.Core.Fritzbox.Networking.Info {
|
6 | 7 | public class ConfigExport {
|
7 | 8 | public static void Collect(AuthUser user, Action<String?> callback) {
|
8 |
| - /*MultipartFormDataContent multipart = new MultipartFormDataContent("WebKitFormBoundaryCtAy6cbSuOvDuO01"); |
9 |
| - multipart.Add(new StringContent("", Encoding.UTF8, "form-data"), "ConfigExport"); |
10 |
| - multipart.Add(new StringContent(password, Encoding.UTF8, "form-data"), "ImportExportPassword"); |
11 |
| - multipart.Add(new StringContent(user.SID, Encoding.UTF8, "form-data"), "sid"); |
12 |
| -
|
13 |
| - multipart.Headers.ContentType.MediaType = "multipart/form-data"; |
14 |
| -
|
15 |
| -
|
16 |
| - System.Diagnostics.Debug.Print(Convert.ToString(multipart));*/ |
17 |
| - |
18 | 9 | String boundary = "CtAy6cbSuOvDuO01";
|
19 | 10 | String password = "test";
|
20 |
| - String request = "------WebKitFormBoundary" + boundary + "\r\nContent-Disposition: form-data; name=\"sid\"\r\n\r\n" + user.SID + "\r\n------WebKitFormBoundary" + boundary + "\r\nContent-Disposition: form-data; name=\"ImportExportPassword\"\r\n\r\n" + password + "\r\n------WebKitFormBoundary" + boundary + "\r\nContent-Disposition: form-data; name=\"ConfigExport\"\r\n\r\n\r\n------WebKitFormBoundary" + boundary + "--"; |
21 | 11 |
|
22 |
| - Request.Post("http://" + user.Endpoint + "/cgi-bin/firmwarecfg", request, delegate (String response) { |
| 12 | + Request.Post("http://" + user.Endpoint + "/cgi-bin/firmwarecfg", new MultipartFormDataContent("----WebKitFormBoundary" + boundary) { |
| 13 | + new FormDataContent("sid", user.SID), |
| 14 | + new FormDataContent("ImportExportPassword", password), |
| 15 | + new FormDataContent("ConfigExport", "") |
| 16 | + }, delegate (String response) { |
23 | 17 | callback(response);
|
24 |
| - }); |
| 18 | + }); |
25 | 19 | }
|
26 | 20 | }
|
27 | 21 | }
|
0 commit comments