Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
BC
public
belle-sip
Commits
7c866849
Commit
7c866849
authored
Feb 12, 2014
by
Simon Morlat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add reporting of channel errors to http listener
parent
a1465c96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
4 deletions
+38
-4
src/http-provider.c
src/http-provider.c
+22
-1
tester/belle_http_tester.c
tester/belle_http_tester.c
+16
-3
No files found.
src/http-provider.c
View file @
7c866849
...
...
@@ -154,6 +154,27 @@ static void http_channel_context_handle_response(belle_http_channel_context_t *c
belle_sip_object_unref
(
req
);
}
static
void
http_channel_context_handle_io_error
(
belle_http_channel_context_t
*
ctx
,
belle_sip_channel_t
*
chan
){
belle_http_request_t
*
req
=
NULL
;
belle_sip_io_error_event_t
ev
=
{
0
};
belle_sip_list_t
*
elem
;
/*if the error happens before attempting to send the message, the pending_requests is empty*/
if
(
ctx
->
pending_requests
==
NULL
)
elem
=
chan
->
outgoing_messages
;
else
elem
=
ctx
->
pending_requests
;
/*pop the requests for which this error is reported*/
for
(;
elem
!=
NULL
;
elem
=
elem
->
next
){
req
=
(
belle_http_request_t
*
)
elem
->
data
;
/*else notify the app about the response received*/
/*TODO: would be nice to put the message in the event*/
ev
.
source
=
(
belle_sip_object_t
*
)
ctx
->
provider
;
ev
.
host
=
chan
->
peer_cname
;
ev
.
port
=
chan
->
peer_port
;
ev
.
transport
=
belle_sip_channel_get_transport_name
(
chan
);
BELLE_HTTP_REQUEST_INVOKE_LISTENER
(
req
,
process_io_error
,
&
ev
);
}
}
static
int
channel_on_event
(
belle_sip_channel_listener_t
*
obj
,
belle_sip_channel_t
*
chan
,
unsigned
int
revents
){
belle_http_channel_context_t
*
ctx
=
BELLE_HTTP_CHANNEL_CONTEXT
(
obj
);
if
(
revents
&
BELLE_SIP_EVENT_READ
){
...
...
@@ -188,7 +209,6 @@ static int channel_on_auth_requested(belle_sip_channel_listener_t *obj, belle_si
static
void
channel_on_sending
(
belle_sip_channel_listener_t
*
obj
,
belle_sip_channel_t
*
chan
,
belle_sip_message_t
*
msg
){
belle_http_channel_context_t
*
ctx
=
BELLE_HTTP_CHANNEL_CONTEXT
(
obj
);
ctx
->
pending_requests
=
belle_sip_list_append
(
ctx
->
pending_requests
,
belle_sip_object_ref
(
msg
));
}
static
void
channel_state_changed
(
belle_sip_channel_listener_t
*
obj
,
belle_sip_channel_t
*
chan
,
belle_sip_channel_state_t
state
){
...
...
@@ -202,6 +222,7 @@ static void channel_state_changed(belle_sip_channel_listener_t *obj, belle_sip_c
case
BELLE_SIP_CHANNEL_RETRY
:
break
;
case
BELLE_SIP_CHANNEL_ERROR
:
http_channel_context_handle_io_error
(
ctx
,
chan
);
case
BELLE_SIP_CHANNEL_DISCONNECTED
:
if
(
!
chan
->
force_close
)
provider_remove_channel
(
ctx
->
provider
,
chan
);
break
;
...
...
tester/belle_http_tester.c
View file @
7c866849
...
...
@@ -108,9 +108,6 @@ static void one_get(const char *url,http_counters_t* counters){
l
=
belle_http_request_listener_create_from_callbacks
(
&
cbs
,
counters
);
belle_http_provider_send_request
(
prov
,
req
,
l
);
wait_for
(
stack
,
&
counters
->
response_count
,
1
,
3000
);
CU_ASSERT_TRUE
(
counters
->
response_count
==
1
);
CU_ASSERT_TRUE
(
counters
->
io_error_count
==
0
);
belle_sip_object_unref
(
l
);
}
...
...
@@ -118,24 +115,39 @@ static void one_get(const char *url,http_counters_t* counters){
static
void
one_http_get
(
void
){
http_counters_t
counters
=
{
0
};
one_get
(
"http://smtp.linphone.org"
,
&
counters
);
CU_ASSERT_TRUE
(
counters
.
response_count
==
1
);
CU_ASSERT_TRUE
(
counters
.
io_error_count
==
0
);
CU_ASSERT_EQUAL
(
counters
.
two_hundred
,
1
);
}
static
void
http_get_io_error
(
void
){
http_counters_t
counters
=
{
0
};
one_get
(
"http://blablabla.cul"
,
&
counters
);
CU_ASSERT_TRUE
(
counters
.
response_count
==
0
);
CU_ASSERT_EQUAL
(
counters
.
io_error_count
,
1
);
}
static
void
one_https_get
(
void
){
http_counters_t
counters
=
{
0
};
one_get
(
"https://smtp.linphone.org"
,
&
counters
);
CU_ASSERT_TRUE
(
counters
.
response_count
==
1
);
CU_ASSERT_TRUE
(
counters
.
io_error_count
==
0
);
CU_ASSERT_EQUAL
(
counters
.
two_hundred
,
1
);
}
static
void
https_get_long_body
(
void
){
http_counters_t
counters
=
{
0
};
one_get
(
"https://www.linphone.org/eng/features/"
,
&
counters
);
CU_ASSERT_TRUE
(
counters
.
response_count
==
1
);
CU_ASSERT_TRUE
(
counters
.
io_error_count
==
0
);
CU_ASSERT_EQUAL
(
counters
.
two_hundred
,
1
);
}
static
void
https_digest_get
(
void
){
http_counters_t
counters
=
{
0
};
one_get
(
"https://pauline:pouet@smtp.linphone.org/restricted"
,
&
counters
);
CU_ASSERT_TRUE
(
counters
.
response_count
==
1
);
CU_ASSERT_TRUE
(
counters
.
io_error_count
==
0
);
CU_ASSERT_EQUAL
(
counters
.
three_hundred
,
1
);
}
#if 0
...
...
@@ -153,6 +165,7 @@ static void https_client_cert_connection(void){
test_t
http_tests
[]
=
{
{
"One http GET"
,
one_http_get
},
{
"One https GET"
,
one_https_get
},
{
"http request with io error"
,
http_get_io_error
},
{
"https GET with long body"
,
https_get_long_body
},
{
"https digest GET"
,
https_digest_get
}
/*, FIXME, nee a server for testing
{ "https with client certificate", https_client_cert_connection }*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment