Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Response body of HTTP GET
Tue, Feb 7 2017 8:07 PMPermanent Link

KimHJ

Comca Systems, Inc

I'm trying to send a response to a HTTP GET but for some reason it does not work.
I know I'm talking to the printer because it sends a POST asking if there is any print jobs, I response with a True or False, if it receives a True it will send a GET requesting the print data. I send the data but nothing prints. If I send the same data to the printer using USB or Ethernet connecting it prints.

Here is what is requested in the manual:
"The server response should include the print job data as the message body, encoded in the
requested format, and with the requested format as the specified content type in the http header."
"Following media types are supported:
text/plain, image/png, application/vnd.star.line, application/vnd.star.linematrix,
application/vnd.star.raster, application/octet-stream"
"The server should set an appropriate "Status: " field in the response header, with one of the
following values.
200 (OK) If the operation succeeded and the job was returned as expected.
404 (not found) If no data is available for printing. "

Here is what I send:

TempStr := 'alll the printers esc codes need for printing';
Request.SendCustomContent(UTF8Encode(TempStr), 'application/vnd.star.line; charset=utf-8','');

And nothing happens.
Thanks for any help.
Kim
Wed, Feb 8 2017 5:20 AMPermanent Link

Walter Matte

Tactical Business Corporation


Install Fiddler and watch the Request and Response... this may be helpful to debug.

http://www.telerik.com/fiddler


Walter
Wed, Feb 8 2017 7:28 AMPermanent Link

Matthew Jones

I was going to suggest using something like POSTman or Paw (Mac!) - any tool that allows you to set up a request and see the response. Heck, for a GET Chrome might do. Fiddler only works with some protocols, not all, and can be complicated to use.

But yes, the core is to see what is actually coming back from the call. You can then tell if the problem is in the code, or in the response. Having has a quick look at the use of 'application/vnd.star.line' I wonder if it could be being affected by string processing, if escapes are used. Again, a tool as above will help answer that.


--

Matthew Jones
Wed, Feb 8 2017 2:35 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Kim,

<< I'm trying to send a response to a HTTP GET but for some reason it does not work. I know I'm talking to the printer because it sends a POST asking if there is any print jobs, I response with a True or False, if it receives a True it will send a GET requesting the print data. I send the data but nothing prints. If I send the same data to the printer using USB or Ethernet connecting it prints. >>

Do you know for a fact that your web server module code is getting called, up to and including the SendCustomContent call ?  You can verify this by running your EWB Web Server Module in the IDE with the host application set to the EWB Web Server (ewbsrvr.exe).

I can do a remote desktop session with you to work through this with you.  It's an interesting example, and won't take long to diagnose.  If you want to do this, just send me an email (timyoung@elevatesoft.com).

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Feb 9 2017 3:46 PMPermanent Link

KimHJ

Comca Systems, Inc

Matthew Jones wrote:

>>I was going to suggest using something like POSTman.

I would not know how to setup the URL in the printer to send it to Postman and I don't know if Postman is listing for incoming request and what port.
Kim


Tim Young [Elevate Software] wrote:

>>Do you know for a fact that your web server module code is getting called, up to and including the SendCustomContent call ?  You can verify this by running your EWB Web Server Module in the IDE with the host application set to the EWB Web Server (ewbsrvr.exe).

That is exactly how I'm doing it. I have it set to Internal Web Server. The module receives the Post, the module  response with True then the printer sends a get, up to here everything is fine.

I will send you an email, thanks.
Thu, Feb 9 2017 9:14 PMPermanent Link

KimHJ

Comca Systems, Inc

I got it to work:
Instead of sending this response:
Request.SendCustomContent(UTF8Encode(TempParam), 'application/vnd.star.line; charset=utf-8','');

I send this.
Request.SendCustomContent(TempParam, 'application/vnd.star.line','');

For some reason it did not like the UTF8.

Thanks,
Kim
Fri, Feb 10 2017 4:41 AMPermanent Link

Matthew Jones

KimHJ wrote:

> For some reason it did not like the UTF8.

You'd have to look at what the SendCustomContent does with the parameter, but I have found that if you double-encode data it can cause problems. So perhaps it already does the encode, so the repeat was breaking it. Glad that you got it working.

--

Matthew Jones
Tue, Feb 14 2017 3:29 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< You'd have to look at what the SendCustomContent does with the parameter, but I have found that if you double-encode data it can cause problems. So perhaps it already does the encode, so the repeat was breaking it. Glad that you got it working. >>

Yes, I need to add some extra information to the manual on these methods to make it more clear what happens with the content with the various versions of the calls.

For now, though, here are the rules:

1) If you're using the Unicode string version of SendCustomContent, then you *need* specify that the content's character set is UTF-8 because that is what EWB will use when converting the Unicode string to bytes when sending the data out to the browser.  I'm going to see if I can make this a little more automatic than that, but it may not be possible.

2) If you're using the ANSI string version of SendCustomContent, then you only need to specify whatever character set the ANSI string (bytes) was encoded in.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Feb 14 2017 3:31 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Kim,

<< I got it to work:
Instead of sending this response:
Request.SendCustomContent(UTF8Encode(TempParam), 'application/vnd.star.line; charset=utf-8','');

I send this.
Request.SendCustomContent(TempParam, 'application/vnd.star.line','');

For some reason it did not like the UTF8. >>

My apologies for not picking up on this - yes, which version of the SendCustomContent call that you use (Unicode/ANSI) will affect how the string is sent out.  Please see my response to Matthew on how this is handled by the EWB module code.

Tim Young
Elevate Software
www.elevatesoft.com
Image