Hello noble monks,
I'm trying to edit http requests on the fly, for that I've got proxy, that intercepts requests, edits them, and then sends them along...
This works fine, until you start POSTing things using some binary encoding... then it apears that my messing with those bytes removes '^M' characters and replaces them with unix newlines ie, incoming request looks like this:
POST /something/fileupload.html^M
HTTP/1.1^M
Accept: image/pjpeg, */*^M
Accept-Language: pl^M
Content-Type: multipart/form-data;
boundary=---------------------------7d42228760176^M
and outgoing looks like this:
POST /something/fileupload.html
HTTP/1.1
Accept: image/pjpeg, */*
Accept-Language: pl
Content-Type: multipart/form-data;
boundary=---------------------------7d42228760176
After receiving such request webservers hang, waiting for client to finish... entering '^M' anywhere makes them continue.
Question is - how to go about this?
My code looks roughly like this:
@indata=split(/^M/,$data);
foreach (@indata) {
$dataout.=$_;
};
... I also tried this:
@indata=split(/^M/,$data);
foreach (@indata) {
push @outdata,$_;
};
$outdata=join(/^M/,@outdata);
But it seems like the only way to put "^M" character in outgoing string is to
$outdata.="^MHelloWorld^M";
Is there some way to make perl use "^M" in newlines? I already tried setting
$/="\r\n";$\="\r\n", but that doesen't change this behaviour.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.