code:
on_before_request(Session oSession)
{
if(oSession.fullUrl=='http../123')
{
oSession.utilCreateResponseAndBypassServer();
oSession.bBufferResponse=false;
my_curl_downloader(oSession.fullUrl,
/*on headers line availible*/delegate(byte[] buf, int size, int nmemb, Object extraData)
{
var header_str=Encoding.UTF8.GetString(buf);
//oSession.oResponse.headers.AssignFromString(header_str);
var header=header_str.split(':');
oSession.oResponse.headers.Add(header[0],header[1]);
},
/*on data availible*/delegate(byte[] buf, int size, int nmemb, Object extraData)
{
oSession.state=SessionStates.ReadingResponse;//?????????????
oSession.responseBodyBytes.append??(buf); //?????????
})
}
}
4 Answers, 1 is accepted
got empty responce
on_before_request(Session oSession)
{
if(oSession.fullUrl=='http../123')
{
oSession.utilCreateResponseAndBypassServer();
oSession.bBufferResponse = false;
oSession.state = SessionStates.ReadingResponse;
new Thread(() =>
{
var headers = new CHeaders();
var req_headers=oSession.oRequest.headers.ToArray();
for(var rh=0;rh<req_headers.Length;rh++)
headers.Append(req_headers[rh].ToString());
List<byte> req_bytes = new List<byte>{};
List<byte> header_bytes = new List<byte> { };
var end = false;
var headers_sended = false;
var md = my_downloader(oSession.fullUrl,headers,
/*on data availible*/delegate(byte[] buf, int size, int nmemb, Object extraData)
{
if (!headers_sended)
{
var headers_str = Encoding.UTF8.GetString(header_bytes.ToArray());
oSession.oResponse.headers.AssignFromString(headers_str);
}
byte[] managedArray = new byte[size];
Marshal.Copy(message, managedArray, 0, size);
req_bytes.AddRange(managedArray);
oSession.ResponseBody=req_bytes.ToArray();
return size*nmemb;
},
/*on headers line availible*/delegate(byte[] buf, int size, int nmemb, Object extraData)
{
header_bytes.AddRange(buf);
return size*nmemb;
}
);
md.Run();
}).Start();
}
}
}
Looking at the provided code, it is difficult to understand what the desired end goal is. Can you provide more information about what you would like to achieve with this?
Once I receive this information I can provide more relevant guidance.
Please let me know if you need any additional information. Thank you for using Fiddler.
Regards,
Eric R
Progress Telerik
sorry bad english
i have stream downloader with difficult logic(p2p)(no sources)
and have a need to patch some bytes in the stream
stream downloader does not have http backend,
stream downloader have api /*on data availible*/
i want using fiddlercore and transmit data from stream downloader as stream.
i can create answer to http request without request to server by
oSession.oFlags["x-replywithtunnel"] ="AutoResponderWithNoFallthrough";
oSession.utilCreateResponseAndBypassServer();
oSession.responseBodyBytes = bytes;
also when proxying real request is availible to patch stream bytes using
oSession.bBufferResponse = false;
and OnReadResponseBuffer callback
is it possible to stream request created by fiddlercore? using AutoResponderWithNoFallthrough and send data stream data from my api
You are correct. Fiddler can stream responses instead of buffering by setting the bBufferResponse flag to false. Although, streamed responses cannot be modified using Fiddler Inspectors. When streaming is enabled for a response, each block of data read from the server is immediately passed to the client application.
I hope this helps. Please let me know if you need any additional information. Thank you.
Regards,
Eric R
Progress Telerik