@@ -29,12 +29,12 @@ use parsec_interface::requests::{
29
29
#[ derivative( Debug ) ]
30
30
pub struct OperationHandler {
31
31
#[ derivative( Debug = "ignore" ) ]
32
- converter : Box < dyn Convert > ,
33
- version_maj : u8 ,
34
- version_min : u8 ,
35
- content_type : BodyType ,
36
- accept_type : BodyType ,
37
- request_client : RequestHandler ,
32
+ pub converter : Box < dyn Convert > ,
33
+ pub wire_protocol_version_maj : u8 ,
34
+ pub wire_protocol_version_min : u8 ,
35
+ pub content_type : BodyType ,
36
+ pub accept_type : BodyType ,
37
+ pub request_handler : RequestHandler ,
38
38
}
39
39
40
40
#[ allow( clippy:: new_without_default) ]
@@ -58,8 +58,8 @@ impl OperationHandler {
58
58
. operation_to_body ( operation)
59
59
. map_err ( ClientErrorKind :: Interface ) ?;
60
60
let header = RequestHeader {
61
- version_maj : self . version_maj ,
62
- version_min : self . version_min ,
61
+ version_maj : self . wire_protocol_version_maj ,
62
+ version_min : self . wire_protocol_version_min ,
63
63
provider,
64
64
session : 0 , // no provisioning of sessions yet
65
65
content_type : self . content_type ,
@@ -110,7 +110,7 @@ impl OperationHandler {
110
110
let req_opcode = operation. opcode ( ) ;
111
111
let request = self . operation_to_request ( operation, provider, auth) ?;
112
112
113
- let response = self . request_client . process_request ( request) ?;
113
+ let response = self . request_handler . process_request ( request) ?;
114
114
self . response_to_result ( response, req_opcode)
115
115
}
116
116
}
@@ -119,11 +119,28 @@ impl Default for OperationHandler {
119
119
fn default ( ) -> Self {
120
120
OperationHandler {
121
121
converter : Box :: from ( ProtobufConverter { } ) ,
122
- version_maj : 1 ,
123
- version_min : 0 ,
122
+ wire_protocol_version_maj : 1 ,
123
+ wire_protocol_version_min : 0 ,
124
124
content_type : BodyType :: Protobuf ,
125
125
accept_type : BodyType :: Protobuf ,
126
- request_client : Default :: default ( ) ,
126
+ request_handler : Default :: default ( ) ,
127
127
}
128
128
}
129
129
}
130
+
131
+ impl crate :: CoreClient {
132
+ /// Set the content type for requests and responses handled by this client
133
+ pub fn set_request_content_type ( & mut self , content_type : BodyType ) {
134
+ self . op_handler . content_type = content_type;
135
+ self . op_handler . accept_type = content_type;
136
+ match content_type {
137
+ BodyType :: Protobuf => self . op_handler . converter = Box :: from ( ProtobufConverter { } ) ,
138
+ }
139
+ }
140
+
141
+ /// Set the wire protocol version numbers to be used by the client
142
+ pub fn set_wire_protocol_version ( & mut self , version_maj : u8 , version_min : u8 ) {
143
+ self . op_handler . wire_protocol_version_maj = version_maj;
144
+ self . op_handler . wire_protocol_version_min = version_min;
145
+ }
146
+ }
0 commit comments