fgenesis / minihttp Goto Github PK
View Code? Open in Web Editor NEWA minimal 2-file (cpp+h) TCP & HTTP client implementation. Supports GET & simple POST. Optional SSL via PolarSSL/mbedTLS. Cross-platform, uses POSIX or Win32 API. C++03 with STL.
A minimal 2-file (cpp+h) TCP & HTTP client implementation. Supports GET & simple POST. Optional SSL via PolarSSL/mbedTLS. Cross-platform, uses POSIX or Win32 API. C++03 with STL.
(bufcap + size + 1 >= bufsz)
changed to (bufsz + size + 1 >= bufcap)
?
I try minihttp::Download but I got http 401 status.
Got HTTP Status 401
How can I process it?
Whilst building, I encountered a warning several times - here is a snippet:
> ./ext/./minihttp/minihttp.cpp:37:44: warning: use of enumeration in a nested name specifier is a C++11 extension [-Wc++11-extensions]
> {OS_TEXT("SSLR_OK"), minihttp::SSLResult::SSLR_OK},
> ^
I was confused at first, but when I put the warning into google, I ended up here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150112/121520.html
If you scroll down, you can see a testcase, which demonstrates this:
+namespace PR16951 {
+ namespace ns {
+ enum an_enumeration {
+ ENUMERATOR // expected-note{{'ENUMERATOR' declared here}}
+ };
+ }
+
+ int x1 = ns::an_enumeration::ENUMERATOR; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}}
So as it turns out, putting an enum into a namespace is C++11 and upwards. I myself was...well, surprised wouldn't suit it. But I would have assumed that naturally, anything can go into a namespace - turns out this is wrong.
So I'd like to ask for these enums to be moved upwards and renamed. It's just two anyway:
minihttp::SSLResult
-> minihttp_SSLResult
minihttp::HttpCode
-> minihttp_HttpCode
I am just suggesting these, but they would make the most sense, and allow non-C++11 compilers to not become confused :)
Basically they changed names. This might affect this library. For backwards compatibility, I'd just suggest adding MINIHTTP_USE_MBEDTLS
analogous to MINIHTTP_USE_POLARSSL
.
Kind regards,
Ingwie
Hey.
I am trying to implement the download and buffer method. I.e.:
std::string mydata = ht->Download("http://google.com");
Kind regards, Ingwie
This should explain it all:
[email protected]_W723_V_Typ_A_1_01_012 ~/W/IceTea $ lldb ./out/icetea
(lldb) target create "./out/icetea"
Current executable set to './out/icetea' (x86_64).
(lldb) process launch -- -e 'minihttp.Download("https://google.com")'
Process 47108 launched: './out/icetea' (x86_64)
-- url: https://google.com
Process 47108 stopped
* thread #1: tid = 0xc5d60d, 0x000000010000ce51 icetea`minihttp::DLSocket::_OnRequestDone(this=0x00007fff5fbfc3e0) + 33 at minihttp.cpp:1357, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x000000010000ce51 icetea`minihttp::DLSocket::_OnRequestDone(this=0x00007fff5fbfc3e0) + 33 at minihttp.cpp:1357
1354 void _OnRequestDone()
1355 {
1356 finished = true;
-> 1357 buf[bufsz] = 0; // zero-terminate
1358 }
1359
1360 void _OnRecv(void *incoming, unsigned size)
(lldb) bt
* thread #1: tid = 0xc5d60d, 0x000000010000ce51 icetea`minihttp::DLSocket::_OnRequestDone(this=0x00007fff5fbfc3e0) + 33 at minihttp.cpp:1357, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
* frame #0: 0x000000010000ce51 icetea`minihttp::DLSocket::_OnRequestDone(this=0x00007fff5fbfc3e0) + 33 at minihttp.cpp:1357
frame #1: 0x0000000100004ad6 icetea`minihttp::HttpSocket::_FinishRequest(this=0x00007fff5fbfc3e0) + 86 at minihttp.cpp:1013
frame #2: 0x00000001000049e3 icetea`minihttp::HttpSocket::_OnUpdate(this=0x00007fff5fbfc3e0) + 131 at minihttp.cpp:832
frame #3: 0x0000000100003d0a icetea`minihttp::TcpSocket::update(this=0x00007fff5fbfc3e0) + 26 at minihttp.cpp:720
frame #4: 0x00000001000086ee icetea`minihttp::Download(url="https://google.com", sz=0x0000000000000000, post=0x0000000000000000) + 510 at minihttp.cpp:1393
frame #5: 0x0000000100001125 icetea`IceTeaHTTP::Download(os=0x0000000100600010, params=1, closure_values=0, need_ret_values=1, userData=0x0000000000000000) + 245 at minihttp.cpp:21
frame #6: 0x0000000100126329 icetea`ObjectScript::OS::Core::callFT(this=0x000000010200f4a8, start_pos=25, call_params=3, ret_values=1, self_for_proto=0x0000000000000000, call_enter=OS_CALLENTER_ALLOW_ONLY_ENTER, call_type=OS_CALLTYPE_AUTO, call_this_usage=OS_CALLTHIS_KEEP_STACK_VALUE) + 2249 at objectscript.cpp:26729
frame #7: 0x000000010011fb98 icetea`ObjectScript::OS::Core::execute(this=0x000000010200f4a8) + 32568 at objectscript.cpp:20618
frame #8: 0x0000000100126214 icetea`ObjectScript::OS::Core::callFT(this=0x000000010200f4a8, start_pos=21, call_params=2, ret_values=1, self_for_proto=0x0000000000000000, call_enter=OS_CALLENTER_EXECUTE_AND_RETURN, call_type=OS_CALLTYPE_FUNC, call_this_usage=OS_CALLTHIS_KEEP_STACK_VALUE) + 1972 at objectscript.cpp:26712
frame #9: 0x00000001000fb078 icetea`ObjectScript::OS::Core::callFT(this=0x000000010200f4a8, params=2, ret_values=1, call_type=OS_CALLTYPE_FUNC, call_this_usage=OS_CALLTHIS_KEEP_STACK_VALUE) + 104 at objectscript.cpp:26831
frame #10: 0x000000010013b890 icetea`ObjectScript::OS::eval(this=0x0000000100600010, str=0x00007fff5fbfec90, params=0, ret_values=1, source_code_type=OS_SOURCECODE_PLAIN, check_utf8_bom=true, handle_exception=false) + 160 at objectscript.cpp:27026
frame #11: 0x000000010013a4b6 icetea`ObjectScript::OS::eval(this=0x0000000100600010, str="minihttp.Download(\"https://google.com\")", params=0, ret_values=1, source_code_type=OS_SOURCECODE_PLAIN, check_utf8_bom=true, handle_exception=false) + 118 at objectscript.cpp:27016
frame #12: 0x00000001000a1cde icetea`IceTea::eval(this=0x0000000100600010, code=<unavailable>, expected=1) + 302 at IceTea.cpp:392
frame #13: 0x00000001000a1a1f icetea`IceTea::checkAndRunInline(this=0x0000000100600010, rt=0x00007fff5fbff6fc) + 3935 at IceTea.cpp:320
frame #14: 0x00000001000a31b1 icetea`IceTea::run(this=0x0000000100600010) + 1089 at IceTea.cpp:467
frame #15: 0x00000001000c78de icetea`main(argc=3, argv=0x00007fff5fbff9e8) + 62 at main.cpp:18
frame #16: 0x00007fff9bad65ad libdyld.dylib`start + 1
frame #17: 0x00007fff9bad65ad libdyld.dylib`start + 1
I mimiced the mbedtls API in the scripting language, and -e
executes a string. From thereon out, you should see where this is going :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.