Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a device that is pushing data to my 'server' application. The device connects and sends a multipart MIME file/stream/string. I can receive this as a stream and convert it to a string, stream, or bytearray, I can parse it to split the data at the MIME boundaries, but I cannot seem to convert the octet stream into anything useful. Here is the MIME data

XML
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SENDDATATRACE"

YES
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODE"

LOGFILEUPLOAD
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SERIALNUMBER"

001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="PASSWORD"

password
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOOPNAME"

001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSIP"

127.0.0.1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSPORT"

-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICE"

1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICENAME"

Power Meter Test 1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPE"

Obvius Power Meter Simulator
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPENUMBER"

-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICECLASS"

74
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MD5CHECKSUM"

edba30720900d5068bdd6a960d8a98c9
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILESIZE"

11240
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILETIME"

2012-12-16 12:29:02
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOGFILE"; filename="/var/log/modbus/mb-001.50CDBE8F_1.log.gz"
Content-Type: application/octet-stream;

� 4�R�}I�d;��OQ��D�p ������*H>�3ϒL�G�pw�I� ��BL�W�/���a��?���/)�^��O*�b���c���O>q�1���)�ϐ���������>9��)|Z�/�o�})�/����2�����?Ώ���AR�I�>����.��s:�����s��<f_�'�5�p����O�s��#�����6{���$]ޘ��3�U�"D��B��4�|r�i�9a�4�3b����㚸�N�������){5�8g-��.C�ي���O|�}��9�c����K�6�9����[i���?��Clϛ}��K�[�چ^W ��O���z�sa��['�lJ������S�Eͩ䁿�
�~�}�'Ŷ{nT��W?a~�n��   �O�:��ߺy;�e��m�20wm��ҧ&�`��į��.W�w��<�^)�|_�B�]�1>���Kɮϼ������I�K�i�'�-�^f�@��s���Ϋ|j��U�T0�T a�.�m)���Pe�ǐ��Ern��Q�}��;��[��گ5Iz�����e�E,���8Eq
tK�O��T��-�=�/G�����G����3�Û���h{�l�Eu���<\A��e�U���>v`\��c6�h2�uoyWl�`�қ��T�z��Sz��u.٦���@U��a2���<��U�-=���56�:���rVM5��.�ؕV1[��z��jS��n�n�$�+S|��e�iSQʹQU�*��O߳�d��oP��3b�����nBت�>���l:��9����  �;`�(�w�jk���j�k�����@��oY�u6�6��EӢ=�5΍�lޭ�m�U�腳���ф9N1���h�T���w7ꠊ?��@�e`dU%~1�q�nq�R�m��`J�:z`ٴR��\�u$�ؗ̅�g�ɲ�c���W���瀾���-&���Q��lg ~��T��o�JҮ�'�П�KR��p�-jǎ�#��P��g����zZ���m!�sV�1�UF��'�:����^8�*ʶ�"T��~՟��8���������W�Z���U�]�`�&!��_�J��o����
�pB��
,{��d�^�,g[�����Kj��h�G�,b4e��v�;�`��V�����ܲ!p�:�h|�]�R��m~�V�)2�E3�+jë�K���_R��(C�#��JS��$�T�װ�%��0��L�Z� ��z�k;�<z^g0~�B����'�}�zY�J���`�P��7(�
�pB�B�nwf���p5х���y{.%&Z�}�/�hn��5ZTP�eѓF��+�S(�
Posted
Updated 25-Mar-18 14:59pm

1 solution

I seems that a majority of the question was cut off. It will not show the rest of the octet-stream in the MIME data, and it did not show the log from the device. Here is the log since I think that will be relevant.

CSS
1/httpupload: LogFileUpload: Begin processing file "/var/log/modbus/mb-001.50CDBE8F_1.log.gz"      ----------------
1/httpupload: TCPConnect: Connecting to server 192.168.1.163:80 (via 192.168.1.163:80).
1/httpupload: TCPConnect: Established connection to server 192.168.1.163:80 (via 192.168.1.163:80).
1/httpupload: SendDataFile: Start file: "/var/log/modbus/mb-001.50CDBE8F_1.log.gz" as "/var/log/modbus/mb-001.50CDBE8F_1.log.gz" (size 11240).
1/httpupload: SendDataFile: Original log filesize = 11240,  total bodysize = 13116.
1/httpupload: SEND: POST  HTTP/1.0
Host: 192.168.1.163:80
1/httpupload: SEND: Connection: close
1/httpupload: SEND: Content-Length: 13116
1/httpupload: SEND: Content-Type: multipart/form-data; boundary=MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
1/httpupload: SEND: Pragma: no-cache
1/httpupload: SEND: Authorization: Basic MDAxRUM2MDUxMjIxOnBhc3N3b3Jk
1/httpupload: SEND: User-Agent: Mozilla/4.0 (compatible; httpupload.c 1.41; Linux; serial 001EC6051221)
1/httpupload: SEND: --MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SENDDATATRACE"
YES
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODE"
LOGFILEUPLOAD
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="SERIALNUMBER"
001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="PASSWORD"
password
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOOPNAME"
001EC6051221
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSIP"
127.0.0.1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSPORT"
-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICE"
1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICENAME"
Power Meter Test 1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPE"
Obvius Power Meter Simulator
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICETYPENUMBER"
-1
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MODBUSDEVICECLASS"
74
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="MD5CHECKSUM"
edba30720900d5068bdd6a960d8a98c9
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILESIZE"
11240
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="FILETIME"
2012-12-16 12:29:02
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY
Content-Disposition: form-data; name="LOGFILE"; filename="/var/log/modbus/mb-001.50CDBE8F_1.log.gz"
Content-Type: application/octet-stream;
1/httpupload: SendDataFile: TCP connection MSS = 1448
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1448 bytes of data
1/httpupload: SendDataFile: Sent 1104 bytes of data
1/httpupload: SEND:
--MIME_BOUNDRY_MIME_BOUNDRY_MIME_BOUNDRY--
1/httpupload: SendDataFile: Finished sending file to remote server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900