LoadLibrary在Win10上的一个坑

LoadLibrary函数在MSDN中有这么一段话

If the string specifies a module name without a path and the file name extension is omitted, the function appends the default library extension .dll to the module name. To prevent the function from appending .dll to the module name, include a trailing point character (.) in the module name string.

也就是LoadLibrary可以加载没有.dll后缀的dll文件,只要在文件后面加个点。

但最近遇到在Windows10系统下面就是败了,GetLastError返回126,至于为什么未知,解决方法就是文件名乖乖加上.dll后缀。


libcurl POST数据大于1024个字节需要注意的问题

    最近在测试libcurl使用代理的功能,发现自己的数据在正常情况下可以post,在使用http代理软件Anon的时候post大于1024个字节时失败了。

尝试其他代理服务器软件又可以,如tinyproxy、kingate,这样只能怀疑是代理服务软件Anon的问题了。

使用IE测163邮箱上传大文件没问题,又怀疑会是否自己代码的问题了。

最后抓包逐一排查发现了这个 Expect: 100-continue 没见过的东西。

谷歌一下得出:

在使用curl做POST的时候, 当要POST的数据大于1024字节的时候, curl并不会直接就发起POST请求, 而是会分为俩步

1. 发送一个请求, 包含一个Expect: 100-continue, 询问Server使用愿意接受数据

2. 接收到Server返回的100-continue应答以后, 才把数据POST给Server

这是libcurl的行为.

具体的RFC相关描述: http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3

于是,这样就有了一个问题, 并不是所有的Server都会正确应答100-continue, 比如lighttpd, 就会返回417 “Expectation Failed”, 则会造成逻辑出错

要解决的办法也挺容易:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); // Disable Expect: header (lighttpd does not support it)

也就是说Anon代理软件也会出这个问题。

参考:http://www.laruence.com/2011/01/20/1840.html


新blog

隔了差不多一年没写日志

由于因为厌烦了WordPress更新和时不时发现bug,14年初就想用go重写blog。

新blog是在空余时间逼着自己一点一点写起来的。

主题是扒了WordPress的,框架用的是beego。

后台丑的没法看只能用,没有任何css、js纯html。

其他功能以后再一点点慢慢完善吧