EmbeddedRelated.com
Forums

RCM3700 HTTP Client on DC9.62

Started by yasj...@ysmgroup.net July 6, 2011
Hi Tom,

The only functions that cause this error are the POSTing functions. GETting functions don't give compile-time errors, although they tend to fail during run-time.

Peter, I've also tried to place everything in one line (and didn't cross the "Butt-ugly-code-beyond-this-gray-border"!) but with the same result.

Anyhow, I might be able to proceed with a GET-method, the problem here is that the strings that I'm trying to post are quite long, over 128 bytes. A colleague advised me to split up the XML-strings and send 'em apart.

This I'll be trying. Thank you guys for the help.

Yasja S.
Hi everybody,
the problem is that the Dynamic C 9.62 compiler doesn't evalute an
expression correctly in the httpc_post_ext function. I don't know if it
is bug or other, but anyway...
Look at the line 1068 of your httpc.lib. You should see as follow:

i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n",
contenttype ? contenttype : "application/x-www-form-urlencoded", plen);

The error is generated by the expression "contenttype ? contenttype :
"application/x-www-form-urlencoded". I think because the printf is a
special function that accepts a variable length array as arguments. If
you change this line to (for example):

if (contenttype)
i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length:
%d\r\n", contenttype, plen);
else
i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length:
%d\r\n", "application/x-www-form-urlencoded", plen);

you should now run your program without any error.

In my case I preferred to leave the library file untouched and rewrite
my own version of this function.

I hope this helps you. Bye.

--- In r..., yasja@... wrote:
>
> Hi Tom,
>
> The only functions that cause this error are the POSTing functions.
GETting functions don't give compile-time errors, although they tend to
fail during run-time.
>
> Peter, I've also tried to place everything in one line (and didn't
cross the "Butt-ugly-code-beyond-this-gray-border"!) but with the same
result.
>
> Anyhow, I might be able to proceed with a GET-method, the problem here
is that the strings that I'm trying to post are quite long, over 128
bytes. A colleague advised me to split up the XML-strings and send 'em
apart.
>
> This I'll be trying. Thank you guys for the help.
>
> Yasja S.
>
I think that DC9 sometimes has problems with complex statements like that one below. A simpler/clearer fix might be to do:

// if Content-Type not provided, use default value

if (! contenttype) contenttype = "application/x-www-form-urlencoded";

i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", contenttype, plen);
-Tom
On Sep 28, 2011, at 3:41 AM, ale_biffo wrote:
> Hi everybody,
> the problem is that the Dynamic C 9.62 compiler doesn't evalute an expression correctly in the httpc_post_ext function. I don't know if it is bug or other, but anyway...
> Look at the line 1068 of your httpc.lib. You should see as follow:
>
> i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", contenttype ? contenttype : "application/x-www-form-urlencoded", plen);
>
> The error is generated by the expression "contenttype ? contenttype : "application/x-www-form-urlencoded". I think because the printf is a special function that accepts a variable length array as arguments. If you change this line to (for example):
>
> if (contenttype)
> i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", contenttype, plen);
> else
> i += sprintf (&buffer[i], "Content-Type: %s\r\nContent-Length: %d\r\n", "application/x-www-form-urlencoded", plen);
>
> you should now run your program without any error.
>
> In my case I preferred to leave the library file untouched and rewrite my own version of this function.
>
> I hope this helps you. Bye.
>
> --- In r..., yasja@... wrote:
> >
> > Hi Tom,
> >
> > The only functions that cause this error are the POSTing functions. GETting functions don't give compile-time errors, although they tend to fail during run-time.
> >
> > Peter, I've also tried to place everything in one line (and didn't cross the "Butt-ugly-code-beyond-this-gray-border"!) but with the same result.
> >
> > Anyhow, I might be able to proceed with a GET-method, the problem here is that the strings that I'm trying to post are quite long, over 128 bytes. A colleague advised me to split up the XML-strings and send 'em apart.
> >
> > This I'll be trying. Thank you guys for the help.
> >
> > Yasja S.
>