I have the following curiosity. If I make a request through TCP/IP to a server, it returns a code that I don't understand what it is or how I can save it.
Summarizing my question: I want to save the response from the server in jpg format , but putting the code that it sends me in a file with a jpg extension does not work (I have copied and pasted it exactly as it arrived). I have made the request through netcat . I'm not looking to save the image with wget or anything, I'd just like to understand what this weird code the server sends me is and why I can't save it to a file and have it work.
I have made the request to the following image:
http://kaboompics.com/files/upload/o_1aqd50lvlpd71hgv10361op4vdk7_new.jpg
This is my request:
GET /files/upload/o_1aqd50lvlpd71hgv10361op4vdk7_new.jpg HTTP/1.1
Host: kaboompics.com
Accept: */*
And this is what I get from the server(response):
HTTP/1.1 200 OK
Cache-Control: public, max-age=2592000
Expires: Sun, 05 Feb 2017 10:39:27 GMT
ETag: "51129-57b4d237-7f06ee67a312ca10"
Last-Modified: Wed, 17 Aug 2016 21:08:07 GMT
Content-Type: image/jpeg
Content-Length: 332073
Date: Fri, 06 Jan 2017 10:39:27 GMT
Accept-Ranges: bytes
Server: LiteSpeed
Connection: close
bodyresponse:
����JFIF��<CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 100
��C��C��,"��
���}!1AQa"q2���#B��R��$3br�
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz���������������������������������������������������������������������������
���w!1AQaq"2�B���� #3R�br�
$4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?��l��Ք��up(s�6�$����1����_5<�H��\E�p&L��s�-���k
i�̑�*�B�89m�xq�3���mXK��+�mPNb� �1�����$�lc�M�/U���4����8ͻ0�G�NH!��np8�I����ח�'�&�##�������$
�b�s�,��ݰ��B�������zц��cر����:�F� ��rWv���F����_�;b�!Fd��d�dr3���
�$��xk� VU�el'$�I �l�0;k*�P�D�����y���7ul3�����,b�I� �BN`�d��嬹����r���������4���gRʬ,�W���a�y� ����|���[sʐE�*�P��3*����$
Đ�ڝ��a!�6�����a� ��8rMq�RZ�һ���s��,�O��z���-���FSQo�ۯ��+�v�����>v��##���*dA�
}��{�BDأ
���B��;�o� ��Q��>�M ��6�x��z�������6ua��|N��墶D(�(�VR�mQ����9�ɵ6ݬ������f��+���� ?C�6��g�ʳ�v�˓�pNk[יʹ�t_���'.%H' �]���̑ɱB�@
�ʏ���
�9�9TX�ֲ�v7vHPcnܪ�*��[���|�8�P:`���M��n6�Եwz��BI?1��\��N9�8$�Yu�$�#�V�v�@��/�@-������.���;*�bU`W8ݴn��e��@ ��WR�R�P�gH�q��� ��2���
�>ﶿ���k����F��E�C"��X���pN0z��%j�����bv��a��+� ��� #�� �m]�X�9a���2ų܀@Q��/ c���aE����}�I �ŕ�9C����Q($�W��y�3�W����: .�y0�� t�������N2�0˾����ɵ�V ��pK�NT��UIukqfUV��s�n*I�\�V-�g��j�/w�c�o��C ���c����0��J߁R��uwo��\x�+yR��.�Å]�,p�
��U$�&���e�)#C.N =nr� yn���v�^>��;C��nr�T�?/
I��T$1=��l���
\�n�Ǣ��@\7TU���ߡ��;�cԯ�H���ݜ�و`�6���$oe�*���]�g,CeF�)�w#vYF�z���>Y%�`']ʹ1�H,݉ �o��#����,����!�;�0*U@^�mb��i�;l����̞g}�o#�㼔ͼH=ξc��QA���pޤ�����$��,��GP�R�[;�$���Am�I��B !���?)dm�7d�!��� �HC1gR����>W%�$���MK����A��_��zp�UeU26���y�@8Tp V�ĮjC~d����ew.�p��͂K|��������8P�2 b�ź��]�v����O#�쵈�I�L�m%���̅R�
����8+�ky~cRk���;��H��60�d��ّ���� �������\�I*�9S�8 (�����ԮO���`��:P��(������2!�8l��NH]ʸ\ORB����\/�H�5����
�جľ��c9V,� �p8䘚�c�Am�)' �,�������Y�n%��3Мc���l��s�I`j��znPA�8PXm|�~\��s�3�Vv-j�hI1_�}�!VS��q�%r�X��U�fS��s��2������e����5�Wl��NH<1��A�$�'ni5���y�'*0H'?9bpr@�x c4Y�����W�>R]�� <��q�Ae'>��"��Yv��� R�`r3���9"�K}�3 ��bU��]��g$�n�FH�k0+�aU�,2�%�f\.8\m�T�2M
5� /�@$���*v+�H�:ڤ�@�L��r�Uf��V.�v���n#8m�p��!rp�c��T�灖;�N�Y�fw��T�����;��� R�\��b���pX(%q��N�z�20A3t�ueu. ,���p@}����2��# QΫr��<�R2pK89
�˒P�KH$@K)S���ew�8*H+���4Y��g��/%��71�B�hP�+��@�韙?0�0Y.�U?:� -�_�F�d�%��1�`�^lߠ,3��@��,9� ���߶��v1�[�"���v�A!Nr����nIo�u:�~��r6���@�3��d�
��T���cnI�s�J��$�e',9J_�)R�pp� $�r���1�9Q�F'R��D!r�'s�9<+(��J�r�y�,��ԓW�θ]�`��T���a�8<�p��#f�h��nU?1�As��,F���prEq1ݙfp�c���X��G`pAi4�������3��!�큲H���B�{!�����[xa?�\��I8 r0HS�B�9I@ܧ9ry<�6���$�N�I�����d�c�`8�FN�� =3���g1H���3�Ӟh'$n��#�[����?����>�NN�I �0��Ċ�����ހd��6�RWkg�q�9|�0$�vo�*>a�H��\|���1�� ,o��ml�ey bH��
F���Z�Y�s�;-�T��6��$�A�U+��6�\d��f#8�
�q��AA�sή��Yv�fffR+�L���T�Mi�(eT��RT�ݥq�>���!r2]�g�f�� �3�1;dÜ���e3����-}v��ڸ����~m��,�+�+Uo��)c�"���v�������#���79�>���9�2O����@\rARWh��c�'
1�K��_�}țkM��_��&���0��s'�ӌs��
J�PY����ڣ��A���U?���b�y�X����\����q g�r:�����1�(UrF���C���0y�$i�^���2�Mǝ3��n^�d���z��6I=v���0Pp�a���n$�*��*@�*v�p
b�p�K�����c���<�q��n+�p��� HTd��3�q��
�)ǶA;)[���U�P�N�ۘ��z|�0(?�ӓ��*^B#)A����6ܜa@$arI=FT1�MD���B�u�$2A�+���'md�kbM�x;�.m���=��Oഝ�Ore$ս�Ȯ|���G.��\��B�a��M�F<���*L������ ���0X��0������
�=� ����/!wQ� +�V��8�ۓ��q�mV �r�݀2ē�1���A�n�n���a.]}�~�3gGi
�T�Ai�lwI��gj� �ug\�2��]�z9V��X&��O�8@�)q�H��Z2d+����E�G@�'��p.�ݷ"���%2�P���.��'5�#/�ha)�'w�z�[\.����*T�*��<��,�8ub �V��@������@wVbp������|��6�o���˴����2Jc�e*+:k��M�y�VC��*
EDIT:
I have spent several days with this doubt and I don't know if I will finally solve it. With Trauma's comment I have passed everything through a hexadecimal editor , leaving the result as follows:
1º Descarga de la imagen original vía web
2º Realización de un request a la imagen vía la web **requestmaker**
3º Realización de un request a la imagen vía **netcat**
From the results I get the following:
1st The original image (saved as image.jpg) occupies 332,073 bytes (325 KiB) on disk . The body that requestmaker gives me is 86,668 bytes (85 KiB) and the response that netcat gives me to the request (including headers and body) is 331,355 bytes (324 KiB) , by deleting the headers and leaving only the body of the file overall size does not vary much.
As you can see this, it makes you think that something is not right because none of the three coincide.
2nd I pass all three through a hexadecimal editor, with the result that both the image.jpg and the request made through the web appear in legible text, somewhat identifying the type of file because the word JPG and the word QUALITY=100 appear . In the file created with netcat directly it is all hexadecimal without readable conversion (all symbols). The only file of the three that can be opened as an image is logically the first downloaded from the web, the others are useless. In addition, the image.jpg file is the only one that has the hexadecimal characters that correspond to an image (FF D8 FF E0)
I can't think of what else I can do.
EDIT 2:
After continuing with the tests one day without knowing the reason, it already works for me. I haven't (consciously) changed anything so I don't know what it could be. When downloading the image with netcat it comes down with the correct size and the correct format. Now I can see it