Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
e3fc5dce
Commit
e3fc5dce
authored
Jan 12, 2014
by
Simon Morlat
Browse files
http test nearly working
parent
12f74f83
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
src/http-message.c
src/http-message.c
+5
-1
src/http-provider.c
src/http-provider.c
+3
-0
tester/belle_http_tester.c
tester/belle_http_tester.c
+11
-1
No files found.
src/http-message.c
View file @
e3fc5dce
...
...
@@ -32,6 +32,7 @@ static void belle_http_request_destroy(belle_http_request_t *req){
if
(
req
->
req_uri
)
belle_sip_object_unref
(
req
->
req_uri
);
DESTROY_STRING
(
req
,
method
)
belle_http_request_set_listener
(
req
,
NULL
);
belle_sip_message
(
"http request destroyed"
);
}
static
void
belle_http_request_clone
(
belle_http_request_t
*
obj
,
const
belle_http_request_t
*
orig
){
...
...
@@ -79,10 +80,13 @@ belle_http_request_t *belle_http_request_create(const char *method, belle_generi
void
belle_http_request_set_listener
(
belle_http_request_t
*
req
,
belle_http_request_listener_t
*
l
){
if
(
req
->
listener
){
belle_sip_object_weak_unref
(
req
->
listener
,(
belle_sip_object_destroy_notify_t
)
belle_http_request_listener_destroyed
,
req
);
belle_sip_message
(
"listener unset"
);
req
->
listener
=
NULL
;
}
if
(
l
)
if
(
l
)
{
belle_sip_object_weak_ref
(
l
,(
belle_sip_object_destroy_notify_t
)
belle_http_request_listener_destroyed
,
req
);
req
->
listener
=
l
;
}
}
belle_http_request_listener_t
*
belle_http_request_get_listener
(
const
belle_http_request_t
*
req
){
...
...
src/http-provider.c
View file @
e3fc5dce
...
...
@@ -32,6 +32,7 @@ struct belle_http_channel_context{
};
struct
belle_http_provider
{
belle_sip_object_t
base
;
belle_sip_stack_t
*
stack
;
char
*
bind_ip
;
int
ai_family
;
...
...
@@ -141,6 +142,7 @@ BELLE_SIP_INSTANCIATE_VPTR(belle_http_channel_context_t,belle_sip_object_t,belle
static
void
http_provider_uninit
(
belle_http_provider_t
*
obj
){
belle_sip_message
(
"http provider destroyed."
);
belle_sip_free
(
obj
->
bind_ip
);
belle_sip_list_for_each
(
obj
->
tcp_channels
,(
void
(
*
)(
void
*
))
belle_sip_channel_force_close
);
belle_sip_list_free_with_data
(
obj
->
tcp_channels
,
belle_sip_object_unref
);
belle_sip_list_for_each
(
obj
->
tls_channels
,(
void
(
*
)(
void
*
))
belle_sip_channel_force_close
);
...
...
@@ -186,6 +188,7 @@ static belle_sip_list_t **provider_get_channels(belle_http_provider_t *obj, cons
static
void
provider_remove_channel
(
belle_http_provider_t
*
obj
,
belle_sip_channel_t
*
chan
){
belle_sip_list_t
**
channels
=
provider_get_channels
(
obj
,
belle_sip_channel_get_transport_name
(
chan
));
*
channels
=
belle_sip_list_remove
(
*
channels
,
chan
);
belle_sip_message
(
"channel [%p] removed from http provider."
,
obj
);
belle_sip_object_unref
(
chan
);
}
...
...
tester/belle_http_tester.c
View file @
e3fc5dce
...
...
@@ -27,6 +27,16 @@ typedef struct http_counters{
int
io_error_count
;
}
http_counters_t
;
static
int
wait_for
(
belle_sip_stack_t
*
s1
,
int
*
counter
,
int
value
,
int
timeout
)
{
int
retry
=
0
;
#define SLEEP_TIME 100
while
(
*
counter
!=
value
&&
retry
++
<
(
timeout
/
SLEEP_TIME
))
{
if
(
s1
)
belle_sip_stack_sleep
(
s1
,
SLEEP_TIME
);
}
if
(
*
counter
!=
value
)
return
FALSE
;
else
return
TRUE
;
}
static
void
process_response
(
void
*
data
,
const
belle_http_response_event_t
*
event
){
http_counters_t
*
counters
=
(
http_counters_t
*
)
data
;
counters
->
response_count
++
;
...
...
@@ -58,7 +68,7 @@ static void one_get(void){
cbs
.
process_io_error
=
process_io_error
;
l
=
belle_http_request_listener_create_from_callbacks
(
&
cbs
,
&
counters
);
belle_http_provider_send_request
(
prov
,
req
,
l
);
belle_sip_stack_sleep
(
stack
,
5
000
);
wait_for
(
stack
,
&
counters
.
response_count
,
1
,
3
000
);
CU_ASSERT_TRUE
(
counters
.
response_count
==
1
);
CU_ASSERT_TRUE
(
counters
.
io_error_count
==
0
);
...
...
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