分块HTTP发布请求:Arduino / telnet

时间:2015-01-16 16:53:00

标签: c bash arduino telnet

这就是我的chunked POST请求的样子。我试图通过分块的POST请求从arduino上的SD卡发送数据块到服务器。需要分块,因为它允许我发送不会全部适合arduino内存的数据。

POST /upload HTTP/1.1
User-Agent: Arduino
Host: ooboontoo
Accept: */*
Transfer-Encoding: chunked

25
this is the text, of this file, wooo!
1d
more test, of this file
0

但是,当服务器尝试解析请求时,我收到错误:

  

{" 25 \ r \ n这是此文件的文字,wooo!\ r \ n" => nil}无效   请求:HTTP格式无效,解析失败。

我尝试阅读chunked requests文档,但似乎有多种方法可以做同样的事情,所以我对 正确方法有点困惑。

任何建议都将不胜感激!

编辑:

这是我写的用于将上述请求输出到telnet的bash代码 运行:./ testit.sh |远程登录

#! /bin/bash
#testit.sh
#Arduino Telnet HTTP POST tests

header="POST /upload HTTP/1.1\n"
header+="User-Agent: Arduino\n"
header+="Host: localhost 3000\n"
header+="Accept: */*\n"
header+="Transfer-Encoding: chunked\n"

thisfile="this is the text, of this file"
thisfilelen=${#thisfile}
printf -v hexlen '%x' $thisfilelen
thisfile2="more test, of this file"
thisfilelen2=${#thisfile2}
printf -v hexlen2 '%x' $thisfilelen2
end="0"


echo "open localhost 3000"
sleep 2
echo -e $header
echo -e $hexlen
echo -e $thisfile
echo -e $hexlen2
echo -e $thisfile2
echo -e $end
sleep 2

0 个答案:

没有答案
相关问题