mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	build: Fix web service functionality. (#6903)
This commit is contained in:
		
							parent
							
								
									6ddf4b241f
								
							
						
					
					
						commit
						b2092de871
					
				
					 7 changed files with 15 additions and 19 deletions
				
			
		|  | @ -1,8 +1,6 @@ | |||
| add_library(web_service STATIC | ||||
|     announce_room_json.cpp | ||||
|     announce_room_json.h | ||||
|     nus_download.cpp | ||||
|     nus_download.h | ||||
|     precompiled_headers.h | ||||
|     telemetry_json.cpp | ||||
|     telemetry_json.h | ||||
|  |  | |||
|  | @ -1,49 +0,0 @@ | |||
| // Copyright 2020 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <memory> | ||||
| #include <httplib.h> | ||||
| #include "common/logging/log.h" | ||||
| #include "web_service/nus_download.h" | ||||
| 
 | ||||
| namespace WebService::NUS { | ||||
| 
 | ||||
| std::optional<std::vector<u8>> Download(const std::string& path) { | ||||
|     constexpr auto HOST = "http://nus.cdn.c.shop.nintendowifi.net"; | ||||
| 
 | ||||
|     std::unique_ptr<httplib::Client> client = std::make_unique<httplib::Client>(HOST); | ||||
|     if (client == nullptr) { | ||||
|         LOG_ERROR(WebService, "Invalid URL {}{}", HOST, path); | ||||
|         return {}; | ||||
|     } | ||||
| 
 | ||||
|     httplib::Request request{ | ||||
|         .method = "GET", | ||||
|         .path = path, | ||||
|         // Needed when httplib is included on android
 | ||||
|         .matches = httplib::Match(), | ||||
|     }; | ||||
| 
 | ||||
|     client->set_follow_location(true); | ||||
|     const auto result = client->send(request); | ||||
|     if (!result) { | ||||
|         LOG_ERROR(WebService, "GET to {}{} returned null", HOST, path); | ||||
|         return {}; | ||||
|     } | ||||
| 
 | ||||
|     const auto& response = result.value(); | ||||
|     if (response.status >= 400) { | ||||
|         LOG_ERROR(WebService, "GET to {}{} returned error status code: {}", HOST, path, | ||||
|                   response.status); | ||||
|         return {}; | ||||
|     } | ||||
|     if (!response.headers.contains("content-type")) { | ||||
|         LOG_ERROR(WebService, "GET to {}{} returned no content", HOST, path); | ||||
|         return {}; | ||||
|     } | ||||
| 
 | ||||
|     return std::vector<u8>(response.body.begin(), response.body.end()); | ||||
| } | ||||
| 
 | ||||
| } // namespace WebService::NUS
 | ||||
|  | @ -1,15 +0,0 @@ | |||
| // Copyright 2020 Citra Emulator Project
 | ||||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <optional> | ||||
| #include <vector> | ||||
| #include "common/common_types.h" | ||||
| 
 | ||||
| namespace WebService::NUS { | ||||
| 
 | ||||
| std::optional<std::vector<u8>> Download(const std::string& path); | ||||
| 
 | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue