Changeset 8
- Timestamp:
- 08/02/07 10:45:53
(1 year ago)
- Author:
- sip
- Message:
Fixed multiple xmlrpc calls in same connection.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r4 |
r8 |
|
| 28 | 28 | static int SendResponse(TSession *r, short code, char *msg, int length); |
|---|
| 29 | 29 | static int SendError(TSession * r, short code); |
|---|
| | 30 | static int SendError(TSession * r, short code, char *msg); |
|---|
| 30 | 31 | |
|---|
| 31 | 32 | protected: |
|---|
| r1 |
r8 |
|
| 56 | 56 | if (r->method != m_post) |
|---|
| 57 | 57 | //Mandamos error |
|---|
| 58 | | return XmlRpcServer::SendError(r, 405); |
|---|
| | 58 | return XmlRpcServer::SendError(r, 405, "Only POST allowed"); |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | //Obtenemos el content type |
|---|
| … | … | |
| 63 | 63 | //Si no es el bueno |
|---|
| 64 | 64 | if (content_type == NULL || strcmp(content_type, "text/xml") != 0) |
|---|
| 65 | | return XmlRpcServer::SendError(r, 400); |
|---|
| | 65 | return XmlRpcServer::SendError(r, 400, "Wrong content-type"); |
|---|
| 66 | 66 | |
|---|
| 67 | 67 | //Obtenemos el content length |
|---|
| … | … | |
| 70 | 70 | //Si no hay |
|---|
| 71 | 71 | if (content_length == NULL) |
|---|
| 72 | | return XmlRpcServer::SendError(r,411); |
|---|
| | 72 | return XmlRpcServer::SendError(r,411,"No content-length"); |
|---|
| 73 | 73 | |
|---|
| 74 | 74 | //Obtenemos el entero |
|---|
| … | … | |
| 77 | 77 | //Tiene que ser mayor que cero |
|---|
| 78 | 78 | if ((inputLen < 0) || (inputLen > xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID))) |
|---|
| 79 | | return XmlRpcServer::SendError(r,400); |
|---|
| | 79 | return XmlRpcServer::SendError(r,400,"Size limit"); |
|---|
| 80 | 80 | |
|---|
| 81 | 81 | //Creamos un buffer para el body |
|---|
| r6 |
r8 |
|
| 648 | 648 | mcu->ReleaseConferenceRef(confId); |
|---|
| 649 | 649 | |
|---|
| 650 | | //Devolvemos el resultado |
|---|
| 651 | | return xmlok(env,xmlrpc_build_value(env,"(i)",res)); |
|---|
| 652 | | } |
|---|
| | 650 | //Salimos |
|---|
| | 651 | if(!res) |
|---|
| | 652 | return xmlerror(env,"Error\n"); |
|---|
| | 653 | |
|---|
| | 654 | //Devolvemos el resultado |
|---|
| | 655 | return xmlok(env); |
|---|
| | 656 | } |
|---|
| r6 |
r8 |
|
| 101 | 101 | |
|---|
| 102 | 102 | //Obtenemos los valores |
|---|
| 103 | | int res = 0; |
|---|
| 104 | | xmlrpc_parse_value(&env,result,"(i)",&res); |
|---|
| 105 | | |
|---|
| 106 | | //Liberamos |
|---|
| 107 | | if (result) |
|---|
| 108 | | xmlrpc_DECREF(result); |
|---|
| 109 | | if (params) |
|---|
| 110 | | xmlrpc_DECREF(params); |
|---|
| 111 | | xmlrpc_env_clean(&env); |
|---|
| 112 | | |
|---|
| 113 | | Log("<CreateConference [%d]\n",res); |
|---|
| 114 | | |
|---|
| 115 | | //Salimos |
|---|
| 116 | | return res; |
|---|
| | 103 | int confId = 0; |
|---|
| | 104 | xmlrpc_parse_value(&env,result,"(i)",&confId); |
|---|
| | 105 | |
|---|
| | 106 | //Liberamos |
|---|
| | 107 | if (result) |
|---|
| | 108 | xmlrpc_DECREF(result); |
|---|
| | 109 | if (params) |
|---|
| | 110 | xmlrpc_DECREF(params); |
|---|
| | 111 | xmlrpc_env_clean(&env); |
|---|
| | 112 | |
|---|
| | 113 | Log("<CreateConference [%d]\n",confId); |
|---|
| | 114 | |
|---|
| | 115 | //Salimos |
|---|
| | 116 | return confId; |
|---|
| 117 | 117 | } |
|---|
| 118 | 118 | |
|---|
| … | … | |
| 168 | 168 | return Error("Error al realizar la operacion\n"); |
|---|
| 169 | 169 | |
|---|
| 170 | | //Obtenemos los valores |
|---|
| 171 | | int res = 0; |
|---|
| 172 | | xmlrpc_parse_value(&env,result,"(i)",&res); |
|---|
| 173 | | |
|---|
| 174 | | //Liberamos |
|---|
| 175 | | if (result) |
|---|
| 176 | | xmlrpc_DECREF(result); |
|---|
| 177 | | if (params) |
|---|
| 178 | | xmlrpc_DECREF(params); |
|---|
| 179 | | xmlrpc_env_clean(&env); |
|---|
| 180 | | |
|---|
| 181 | | Log("<SetCompositionType [%d,%d]\n",confId,res); |
|---|
| 182 | | |
|---|
| 183 | | //Salimos |
|---|
| 184 | | return res; |
|---|
| | 170 | //Liberamos |
|---|
| | 171 | if (result) |
|---|
| | 172 | xmlrpc_DECREF(result); |
|---|
| | 173 | if (params) |
|---|
| | 174 | xmlrpc_DECREF(params); |
|---|
| | 175 | xmlrpc_env_clean(&env); |
|---|
| | 176 | |
|---|
| | 177 | Log("<SetCompositionType\n",confId); |
|---|
| | 178 | |
|---|
| | 179 | //Salimos |
|---|
| | 180 | return true; |
|---|
| 185 | 181 | } |
|---|
| 186 | 182 | |
|---|
| … | … | |
| 206 | 202 | |
|---|
| 207 | 203 | //Obtenemos los valores |
|---|
| 208 | | int res = 0; |
|---|
| 209 | | xmlrpc_parse_value(&env,result,"(i)",&res); |
|---|
| 210 | | |
|---|
| 211 | | //Liberamos |
|---|
| 212 | | if (result) |
|---|
| 213 | | xmlrpc_DECREF(result); |
|---|
| 214 | | if (params) |
|---|
| 215 | | xmlrpc_DECREF(params); |
|---|
| 216 | | xmlrpc_env_clean(&env); |
|---|
| 217 | | |
|---|
| 218 | | Log("<CreateParticipant [%d,%d]\n",confId,res); |
|---|
| 219 | | |
|---|
| 220 | | //Salimos |
|---|
| 221 | | return res; |
|---|
| | 204 | int partId = 0; |
|---|
| | 205 | xmlrpc_parse_value(&env,result,"(i)",&partId); |
|---|
| | 206 | |
|---|
| | 207 | //Liberamos |
|---|
| | 208 | if (result) |
|---|
| | 209 | xmlrpc_DECREF(result); |
|---|
| | 210 | if (params) |
|---|
| | 211 | xmlrpc_DECREF(params); |
|---|
| | 212 | xmlrpc_env_clean(&env); |
|---|
| | 213 | |
|---|
| | 214 | Log("<CreateParticipant [%d,%d]\n",confId,partId); |
|---|
| | 215 | |
|---|
| | 216 | //Salimos |
|---|
| | 217 | return partId; |
|---|
| 222 | 218 | } |
|---|
| 223 | 219 | |
|---|
| r4 |
r8 |
|
| 141 | 141 | { |
|---|
| 142 | 142 | int len=0; |
|---|
| 143 | | |
|---|
| 144 | 143 | |
|---|
| 145 | 144 | //Obtenemos lo que quedaba en el buffer |
|---|
| … | … | |
| 155 | 154 | memcpy(body,r->conn->buffer,len); |
|---|
| 156 | 155 | |
|---|
| 157 | | |
|---|
| 158 | 156 | //MIentras no hayamos leido del todo |
|---|
| 159 | 157 | while (len<bodyLen) |
|---|
| … | … | |
| 179 | 177 | //Incrementamos el buffer |
|---|
| 180 | 178 | len += size; |
|---|
| | 179 | |
|---|
| | 180 | //Increase buffer pos |
|---|
| | 181 | r->conn->bufferpos += len; |
|---|
| 181 | 182 | } |
|---|
| | 183 | |
|---|
| | 184 | //Reset buffer |
|---|
| | 185 | r->conn->buffersize = 0; |
|---|
| | 186 | r->conn->bufferpos = 0; |
|---|
| | 187 | |
|---|
| | 188 | //Clean buffer |
|---|
| | 189 | ConnReadInit(r->conn); |
|---|
| 182 | 190 | |
|---|
| 183 | 191 | //Salimos bien |
|---|
| … | … | |
| 222 | 230 | return SendResponse(r,code,ERRORMSG,strlen(ERRORMSG)); |
|---|
| 223 | 231 | } |
|---|
| | 232 | |
|---|
| | 233 | /************************************** |
|---|
| | 234 | * SendError |
|---|
| | 235 | * Devuelve el html con el error |
|---|
| | 236 | **************************************/ |
|---|
| | 237 | int XmlRpcServer::SendError(TSession * r, short code,char *msg) |
|---|
| | 238 | { |
|---|
| | 239 | //POnemos el content type |
|---|
| | 240 | ResponseContentType(r, "text/html; charset=\"utf-8\""); |
|---|
| | 241 | |
|---|
| | 242 | //Escribimos el codigo de error |
|---|
| | 243 | return SendResponse(r,code,msg,strlen(msg)); |
|---|
| | 244 | } |
|---|
Download in other formats:
|
|