您的位置:首页 > 编程语言 > Go语言

GoAhead网页提交内容

2015-08-18 22:24 411 查看
<span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">提交的方式有两种get和post</span><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">get:</div><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">    这种传送方式所传输的内容有长度限制,一般在一百多字节以内。但是它所传送的 特殊字符 不需要的转换。</div><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><br style="background-color: inherit;" /></div><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">post:</div><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">    这种传送方式的内容可以比较大,可以大于2048字节,传送文件也是用这种方式,传送文件需要在form里添加</div><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">enctype="multipart/form-data"。</div><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">    post不加文件传输方式的话,传送的内容和get的一样,不过特殊字符就需要自己手动转换如:</div><blockquote style="font: 14px/21px 微软雅黑; margin: 0px 0px 0px 40px; padding: 0px; border: currentColor; border-image: none; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"><div style="background-color: inherit;">1. + URL 中+号表示空格 %2B</div><div style="background-color: inherit;">2. 空格 URL中的空格可以用+号或者编码 %20</div><div style="background-color: inherit;">3. / 分隔目录和子目录 %2F</div><div style="background-color: inherit;">4. ? 分隔实际的 URL 和参数 %3F</div><div style="background-color: inherit;">5. % 指定特殊字符 %25</div><div style="background-color: inherit;">6. # 表示书签 %23</div><div style="background-color: inherit;">7. & URL 中指定的参数间的分隔符 %26</div><div style="background-color: inherit;">8. = URL 中指定参数的值 %3D</div></blockquote><span style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">    这些特殊字符以经过提交时防止出错转换的,转换的规则是“%”+“特殊字符的ascii码的十六进制”,</span><div style="font: 14px/21px 微软雅黑; text-align: left; color: rgb(0, 0, 0); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;">转换的函数可以参考:</div>
 
void WebTransUrl(const char *apcSrc, char* apcDst, int aiSize){int i = 0;int lnDstId = 0;while((i < aiSize - 1) && apcSrc[i]){if ('+' == apcSrc[i]){apcDst[lnDstId] = ' ';}else if ('%' == apcSrc[i]){apcDst[lnDstId] = (((unsigned char)apcSrc[i + 1] - '0') << 4 ) | ((unsigned char)apcSrc[i + 2] - '0');i += 2;}else{apcDst[lnDstId] = apcSrc[i];}++i;++lnDstId;}apcDst[lnDstId] = 0;}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: