Saving the specific content type
Thanks Alex for helping me for dealing with POST messages. I am looking- further down to just save the contents of the packets which have content-type as application/json (in other words specific content type only.) I can check the content-type in the header in start() function. But I want to just save the contents of json. Kindly suggest which function will be best to start with.
Thanks
Sandeep
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- eCAP Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Sandeep Kuttal
- Solved:
- Last query:
- Last reply:
Revision history for this message
![]() |
#1 |
You can save virgin message headers in start().
You can save virgin message body bytes in libecap:
Revision history for this message
![]() |
#2 |
Thanks Alex. Actually I was already doing this. Let me elaborate what I want to do..
For my research I need to see
1) the URI of the server interacting with client.
2) Need to just save application/json formats in files but leeting all other contents to pass by
Revision history for this message
![]() |
#3 |
What I have done till now is
I am able to see the json format in start function. I was already capturing all the messages in the libecap:
so i need to just save the json format contents (that too for specific uri) and let all other messages pass. Kindly suggest..
Revision history for this message
![]() |
#4 |
What I have done till now is
I am able to see the json format in start function. I was already capturing all the messages in the libecap:
so i need to just save the json format contents (that too for specific uri) and let all other messages pass. Kindly suggest..
Revision history for this message
![]() |
#5 |
What I have done till now is
I am able to see the json format in start function. I was already capturing all the messages in the libecap:
so i need to just save the json format contents (that too for specific uri) and let all other messages pass. Kindly suggest..
Revision history for this message
![]() |
#6 |
In Adapter:
As for accessing the Request URI, you can get it from the hostx->virgin() or hostx->cause() message, depending on whether you are doing REQMOD or RESPMOD. Once you have a message pointer, use firstLine() method to get RequestLine. Once you have RequestLine, call its uri() method.
Revision history for this message
![]() |
#7 |
Hi Alex,
Thanks again for your constant support. I have made few changes to the code which are as below:
libecap:
// Lines added just testing for getting URI //sandeep
std::string uri_req1 = requestLine1-
The problem now I am facing is that on starting the browser I am not able to see the contents for the sites. Sometimes on refreshing I see the proxy connection refusal. I was creating a file to store the contents of the body in libecap:
std::string uri_req1 = requestLine1-
is bringing all the trouble.
Can you kindly give a look to this code and let me know what is going wrong?
Thanks
Sandeep
(I want to get the url of all the servers which are refereed by the website. Will this be possible with the above code. )
Revision history for this message
![]() |
#8 |
after this code I think all other code doesn't work at all. Since I was creating files for checking JSON format and another file for saving the contents which I can no more find now.
Revision history for this message
![]() |
#9 |
Perhaps requestLine1 is nil after dynamic_cast because virgin() is a response because you are in a RESPMOD? In RESPMOD, you should use cause() instead of virgin() to get to the request message.
Even if requestLine1 is not nil in your test case, you should not dynamic_cast to a pointer and then dereference the result without checking the resulting pointer for being nil.
Revision history for this message
![]() |
#10 |
Yes, you are right. It was getting a NULL pointer. However, using cause() is resulting in an error and the code is not compiling. This is the changes I made:
libecap:
// Lines added just testing for getting URI //sandeep
std::string uri_req1;
if (! requestLine1)
else
Revision history for this message
![]() |
#11 |
I forgot to paste the error message. I have pasted it below, if it helps.
adapter_
adapter_
make[2]: *** [adapter_
Can you please tell what I am missing here? Thanks a lot again for all your help.
Revision history for this message
![]() |
#12 |
You must use constant firstLine1 because cause() (i.e., the request that caused the current virgin response) cannot be modified.
Technically, the virgin() message should not be modified either. I am not sure why we did not make that method constant. Perhaps that will change in future releases.
Revision history for this message
![]() |
#13 |
Hi Alex,
I changed the firstline to constant for cause. The code I changed is as follows
const libecap::FirstLine *firstLine1 = &(hostx-
const libecap:
std::string uri_req1;
if (! requestLine1)
else
std::ofstream myfile;
// myfile << contentTypeString1;
The code compiled successfully but on opening browser got ICAP protocol error.
Kindly suggest whats going wrong?
Thanks
Revision history for this message
![]() |
#14 |
You need to enable verbose Squid logging (debug_options ALL,9) and try to understand what caused the error response. I cannot tell by looking at your code excerpt.
Revision history for this message
![]() |
#15 |
Hi Alex,
I checked my log file and couldn't find the exact cause. Is it because of some locks or some other reason. I have uploaded my log file on following link:
http://
Start from line 90800 for this problem.
client_
Can you kindly give a look since I am not able to figure out what's going wrong.
Thanks
Sandeep
(P.S The code is same as pasted above and I didn't made any changes in other parts of the file)
When I was using the hostx->
Revision history for this message
![]() |
#16 |
2010/08/20 00:45:49.884| AsyncJob.cc(218) dial: AsyncJob::noteStart threw exception: theCauseRep != NULL
2010/08/20 00:45:49.884| Adaptation:
2010/08/20 00:45:49.884| AsyncJob:
2010/08/20 00:45:49.884| Initiate.cc(51) swanSong: fatal failure; sending abort notification
You are probably calling the cause() method in REQMOD, resulting in an exception:
const libecap::Message &
Adaptation:
{
Must(
return *theCauseRep;
}
See my earlier comments on how to get to the Request-URI in REQMOD and RESPMOD. The method differs depending on the adaptation mode.
Revision history for this message
![]() |
#17 |
Hi Alex,
Can you tell how to access request message of REQMOD ?
Thanks
Revision history for this message
![]() |
#18 |
host::Xaction:
Revision history for this message
![]() |
#19 |
Actually I was using the same function before also. But i was getting exception when i tried to dynamic cast the RequestLine
libecap:
and requestLine is returning null pointer.
Revision history for this message
![]() |
#20 |
sorry for wrong information it is not giving any exception. But I am not getting any contents on the browser
Revision history for this message
![]() |
#21 |
Thanks Alex actually now I can see the contents.. Will look for url ad let you know
Revision history for this message
![]() |
#22 |
Hi Alex,
Can you tell functions in ecap to access
REQMOD
request message
response message
RESPMOD
request message
response message
Thanks
Sandeep
Revision history for this message
![]() |
#23 |
REQMOD request: host::Xaction:
REQMOD response: there is no response
RESPMOD request: host::Xaction:
RESPMOD response: host::Xaction: