First you need to decode the data. You can use this link .
All spaces are replaced by + , and all numbers after % are special - 2-digit hexadecimal encoded numbers - special characters with URL encoding (for example, + } , etc.).).
For example, you code will be translated into:
#include <stdio.h>\r\nint main( int argc, char **argv) {\r\n return 0;\r\n}
Where \r\n is CRLF, So from this you finally get:
#include <stdio.h> int main( int argc, char **argv) { return 0; }
which is exactly your code. Then you can write it to your temporary file and try to compile it.
Some things that come to my mind for a better application, such as:
- make it multithreaded - you can process more than one such request at a time
- add several queues for the received data - do not lose the data that comes in while your program processes the current request (queue queue)
- Of course, sync threads and be careful with this
- I think you will need IPC (Inter-Process Communication) - to communicate with your compiler process and to get errors, it gives you (unless you have a special API provided for your compiler)
Of course, these are just some of the tips that come to me. This would be a great exercise for any developer - IPC + multithreading + network programming + http! Excellent:)
Good luck.
source share