Skip to content

Commit 08fc708

Browse files
committed
Fixed #456
1 parent 8333340 commit 08fc708

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

httplib.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,8 +1515,8 @@ inline bool bind_ip_address(socket_t sock, const char *host) {
15151515
return ret;
15161516
}
15171517

1518-
inline std::string if2ip(const std::string &ifn) {
15191518
#ifndef _WIN32
1519+
inline std::string if2ip(const std::string &ifn) {
15201520
struct ifaddrs *ifap;
15211521
getifaddrs(&ifap);
15221522
for (auto ifa = ifap; ifa; ifa = ifa->ifa_next) {
@@ -1532,19 +1532,21 @@ inline std::string if2ip(const std::string &ifn) {
15321532
}
15331533
}
15341534
freeifaddrs(ifap);
1535-
#endif
15361535
return std::string();
15371536
}
1537+
#endif
15381538

15391539
inline socket_t create_client_socket(const char *host, int port,
15401540
time_t timeout_sec,
15411541
const std::string &intf) {
15421542
return create_socket(
15431543
host, port, [&](socket_t sock, struct addrinfo &ai) -> bool {
15441544
if (!intf.empty()) {
1545+
#ifndef _WIN32
15451546
auto ip = if2ip(intf);
15461547
if (ip.empty()) { ip = intf; }
15471548
if (!bind_ip_address(sock, ip.c_str())) { return false; }
1549+
#endif
15481550
}
15491551

15501552
set_nonblocking(sock, true);
@@ -2849,11 +2851,11 @@ inline void Response::set_header(const char *key, const std::string &val) {
28492851
}
28502852
}
28512853

2852-
inline void Response::set_redirect(const char *url, int status) {
2854+
inline void Response::set_redirect(const char *url, int stat) {
28532855
if (!detail::has_crlf(url)) {
28542856
set_header("Location", url);
2855-
if (300 <= status && status < 400) {
2856-
this->status = status;
2857+
if (300 <= stat && stat < 400) {
2858+
this->status = stat;
28572859
} else {
28582860
this->status = 302;
28592861
}

test/test.vcxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<ClCompile>
9292
<PrecompiledHeader>
9393
</PrecompiledHeader>
94-
<WarningLevel>Level3</WarningLevel>
94+
<WarningLevel>Level4</WarningLevel>
9595
<Optimization>Disabled</Optimization>
9696
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9797
<AdditionalIncludeDirectories>./;../</AdditionalIncludeDirectories>
@@ -108,7 +108,7 @@
108108
<ClCompile>
109109
<PrecompiledHeader>
110110
</PrecompiledHeader>
111-
<WarningLevel>Level3</WarningLevel>
111+
<WarningLevel>Level4</WarningLevel>
112112
<Optimization>Disabled</Optimization>
113113
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
114114
<AdditionalIncludeDirectories>./;../</AdditionalIncludeDirectories>
@@ -118,12 +118,12 @@
118118
<Link>
119119
<SubSystem>Console</SubSystem>
120120
<GenerateDebugInformation>true</GenerateDebugInformation>
121-
<AdditionalDependencies>Ws2_32.lib;AdditionalDependencies)</AdditionalDependencies>
121+
<AdditionalDependencies>Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
122122
</Link>
123123
</ItemDefinitionGroup>
124124
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
125125
<ClCompile>
126-
<WarningLevel>Level3</WarningLevel>
126+
<WarningLevel>Level4</WarningLevel>
127127
<PrecompiledHeader>
128128
</PrecompiledHeader>
129129
<Optimization>MaxSpeed</Optimization>
@@ -144,7 +144,7 @@
144144
</ItemDefinitionGroup>
145145
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
146146
<ClCompile>
147-
<WarningLevel>Level3</WarningLevel>
147+
<WarningLevel>Level4</WarningLevel>
148148
<PrecompiledHeader>
149149
</PrecompiledHeader>
150150
<Optimization>MaxSpeed</Optimization>
@@ -171,4 +171,4 @@
171171
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
172172
<ImportGroup Label="ExtensionTargets">
173173
</ImportGroup>
174-
</Project>
174+
</Project>

0 commit comments

Comments
 (0)