We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -57,311 +57,311 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | class Apache_Solr_Document implements IteratorAggregate |
| 59 | 59 | { |
| 60 | - /** |
|
| 61 | - * SVN Revision meta data for this class |
|
| 62 | - */ |
|
| 63 | - const SVN_REVISION = '$Revision: 54 $'; |
|
| 60 | + /** |
|
| 61 | + * SVN Revision meta data for this class |
|
| 62 | + */ |
|
| 63 | + const SVN_REVISION = '$Revision: 54 $'; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * SVN ID meta data for this class |
|
| 67 | - */ |
|
| 68 | - const SVN_ID = '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; |
|
| 65 | + /** |
|
| 66 | + * SVN ID meta data for this class |
|
| 67 | + */ |
|
| 68 | + const SVN_ID = '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Document boost value |
|
| 72 | - * |
|
| 73 | - * @var float |
|
| 74 | - */ |
|
| 75 | - protected $_documentBoost = false; |
|
| 70 | + /** |
|
| 71 | + * Document boost value |
|
| 72 | + * |
|
| 73 | + * @var float |
|
| 74 | + */ |
|
| 75 | + protected $_documentBoost = false; |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Document field values, indexed by name |
|
| 79 | - * |
|
| 80 | - * @var array |
|
| 81 | - */ |
|
| 82 | - protected $_fields = array(); |
|
| 77 | + /** |
|
| 78 | + * Document field values, indexed by name |
|
| 79 | + * |
|
| 80 | + * @var array |
|
| 81 | + */ |
|
| 82 | + protected $_fields = array(); |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Document field boost values, indexed by name |
|
| 86 | - * |
|
| 87 | - * @var array array of floats |
|
| 88 | - */ |
|
| 89 | - protected $_fieldBoosts = array(); |
|
| 84 | + /** |
|
| 85 | + * Document field boost values, indexed by name |
|
| 86 | + * |
|
| 87 | + * @var array array of floats |
|
| 88 | + */ |
|
| 89 | + protected $_fieldBoosts = array(); |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Clear all boosts and fields from this document |
|
| 93 | - */ |
|
| 94 | - public function clear() |
|
| 95 | - { |
|
| 96 | - $this->_documentBoost = false; |
|
| 91 | + /** |
|
| 92 | + * Clear all boosts and fields from this document |
|
| 93 | + */ |
|
| 94 | + public function clear() |
|
| 95 | + { |
|
| 96 | + $this->_documentBoost = false; |
|
| 97 | 97 | |
| 98 | - $this->_fields = array(); |
|
| 99 | - $this->_fieldBoosts = array(); |
|
| 100 | - } |
|
| 98 | + $this->_fields = array(); |
|
| 99 | + $this->_fieldBoosts = array(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Get current document boost |
|
| 104 | - * |
|
| 105 | - * @return mixed will be false for default, or else a float |
|
| 106 | - */ |
|
| 107 | - public function getBoost() |
|
| 108 | - { |
|
| 109 | - return $this->_documentBoost; |
|
| 110 | - } |
|
| 102 | + /** |
|
| 103 | + * Get current document boost |
|
| 104 | + * |
|
| 105 | + * @return mixed will be false for default, or else a float |
|
| 106 | + */ |
|
| 107 | + public function getBoost() |
|
| 108 | + { |
|
| 109 | + return $this->_documentBoost; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Set document boost factor |
|
| 114 | - * |
|
| 115 | - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 116 | - */ |
|
| 117 | - public function setBoost($boost) |
|
| 118 | - { |
|
| 119 | - $boost = (float) $boost; |
|
| 112 | + /** |
|
| 113 | + * Set document boost factor |
|
| 114 | + * |
|
| 115 | + * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 116 | + */ |
|
| 117 | + public function setBoost($boost) |
|
| 118 | + { |
|
| 119 | + $boost = (float) $boost; |
|
| 120 | 120 | |
| 121 | - if ($boost > 0.0) |
|
| 122 | - { |
|
| 123 | - $this->_documentBoost = $boost; |
|
| 124 | - } |
|
| 125 | - else |
|
| 126 | - { |
|
| 127 | - $this->_documentBoost = false; |
|
| 128 | - } |
|
| 129 | - } |
|
| 121 | + if ($boost > 0.0) |
|
| 122 | + { |
|
| 123 | + $this->_documentBoost = $boost; |
|
| 124 | + } |
|
| 125 | + else |
|
| 126 | + { |
|
| 127 | + $this->_documentBoost = false; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * Add a value to a multi-valued field |
|
| 133 | - * |
|
| 134 | - * NOTE: the solr XML format allows you to specify boosts |
|
| 135 | - * PER value even though the underlying Lucene implementation |
|
| 136 | - * only allows a boost per field. To remedy this, the final |
|
| 137 | - * field boost value will be the product of all specified boosts |
|
| 138 | - * on field values - this is similar to SolrJ's functionality. |
|
| 139 | - * |
|
| 140 | - * <code> |
|
| 141 | - * $doc = new Apache_Solr_Document(); |
|
| 142 | - * |
|
| 143 | - * $doc->addField('foo', 'bar', 2.0); |
|
| 144 | - * $doc->addField('foo', 'baz', 3.0); |
|
| 145 | - * |
|
| 146 | - * // resultant field boost will be 6! |
|
| 147 | - * echo $doc->getFieldBoost('foo'); |
|
| 148 | - * </code> |
|
| 149 | - * |
|
| 150 | - * @param string $key |
|
| 151 | - * @param mixed $value |
|
| 152 | - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 153 | - */ |
|
| 154 | - public function addField($key, $value, $boost = false) |
|
| 155 | - { |
|
| 156 | - if (!isset($this->_fields[$key])) |
|
| 157 | - { |
|
| 158 | - // create holding array if this is the first value |
|
| 159 | - $this->_fields[$key] = array(); |
|
| 160 | - } |
|
| 161 | - else if (!is_array($this->_fields[$key])) |
|
| 162 | - { |
|
| 163 | - // move existing value into array if it is not already an array |
|
| 164 | - $this->_fields[$key] = array($this->_fields[$key]); |
|
| 165 | - } |
|
| 131 | + /** |
|
| 132 | + * Add a value to a multi-valued field |
|
| 133 | + * |
|
| 134 | + * NOTE: the solr XML format allows you to specify boosts |
|
| 135 | + * PER value even though the underlying Lucene implementation |
|
| 136 | + * only allows a boost per field. To remedy this, the final |
|
| 137 | + * field boost value will be the product of all specified boosts |
|
| 138 | + * on field values - this is similar to SolrJ's functionality. |
|
| 139 | + * |
|
| 140 | + * <code> |
|
| 141 | + * $doc = new Apache_Solr_Document(); |
|
| 142 | + * |
|
| 143 | + * $doc->addField('foo', 'bar', 2.0); |
|
| 144 | + * $doc->addField('foo', 'baz', 3.0); |
|
| 145 | + * |
|
| 146 | + * // resultant field boost will be 6! |
|
| 147 | + * echo $doc->getFieldBoost('foo'); |
|
| 148 | + * </code> |
|
| 149 | + * |
|
| 150 | + * @param string $key |
|
| 151 | + * @param mixed $value |
|
| 152 | + * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 153 | + */ |
|
| 154 | + public function addField($key, $value, $boost = false) |
|
| 155 | + { |
|
| 156 | + if (!isset($this->_fields[$key])) |
|
| 157 | + { |
|
| 158 | + // create holding array if this is the first value |
|
| 159 | + $this->_fields[$key] = array(); |
|
| 160 | + } |
|
| 161 | + else if (!is_array($this->_fields[$key])) |
|
| 162 | + { |
|
| 163 | + // move existing value into array if it is not already an array |
|
| 164 | + $this->_fields[$key] = array($this->_fields[$key]); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - if ($this->getFieldBoost($key) === false) |
|
| 168 | - { |
|
| 169 | - // boost not already set, set it now |
|
| 170 | - $this->setFieldBoost($key, $boost); |
|
| 171 | - } |
|
| 172 | - else if ((float) $boost > 0.0) |
|
| 173 | - { |
|
| 174 | - // multiply passed boost with current field boost - similar to SolrJ implementation |
|
| 175 | - $this->_fieldBoosts[$key] *= (float) $boost; |
|
| 176 | - } |
|
| 167 | + if ($this->getFieldBoost($key) === false) |
|
| 168 | + { |
|
| 169 | + // boost not already set, set it now |
|
| 170 | + $this->setFieldBoost($key, $boost); |
|
| 171 | + } |
|
| 172 | + else if ((float) $boost > 0.0) |
|
| 173 | + { |
|
| 174 | + // multiply passed boost with current field boost - similar to SolrJ implementation |
|
| 175 | + $this->_fieldBoosts[$key] *= (float) $boost; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - // add value to array |
|
| 179 | - $this->_fields[$key][] = $value; |
|
| 180 | - } |
|
| 178 | + // add value to array |
|
| 179 | + $this->_fields[$key][] = $value; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Handle the array manipulation for a multi-valued field |
|
| 184 | - * |
|
| 185 | - * @param string $key |
|
| 186 | - * @param string $value |
|
| 187 | - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 188 | - * |
|
| 189 | - * @deprecated Use addField(...) instead |
|
| 190 | - */ |
|
| 191 | - public function setMultiValue($key, $value, $boost = false) |
|
| 192 | - { |
|
| 193 | - $this->addField($key, $value, $boost); |
|
| 194 | - } |
|
| 182 | + /** |
|
| 183 | + * Handle the array manipulation for a multi-valued field |
|
| 184 | + * |
|
| 185 | + * @param string $key |
|
| 186 | + * @param string $value |
|
| 187 | + * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 188 | + * |
|
| 189 | + * @deprecated Use addField(...) instead |
|
| 190 | + */ |
|
| 191 | + public function setMultiValue($key, $value, $boost = false) |
|
| 192 | + { |
|
| 193 | + $this->addField($key, $value, $boost); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - /** |
|
| 197 | - * Get field information |
|
| 198 | - * |
|
| 199 | - * @param string $key |
|
| 200 | - * @return mixed associative array of info if field exists, false otherwise |
|
| 201 | - */ |
|
| 202 | - public function getField($key) |
|
| 203 | - { |
|
| 204 | - if (isset($this->_fields[$key])) |
|
| 205 | - { |
|
| 206 | - return array( |
|
| 207 | - 'name' => $key, |
|
| 208 | - 'value' => $this->_fields[$key], |
|
| 209 | - 'boost' => $this->getFieldBoost($key) |
|
| 210 | - ); |
|
| 211 | - } |
|
| 196 | + /** |
|
| 197 | + * Get field information |
|
| 198 | + * |
|
| 199 | + * @param string $key |
|
| 200 | + * @return mixed associative array of info if field exists, false otherwise |
|
| 201 | + */ |
|
| 202 | + public function getField($key) |
|
| 203 | + { |
|
| 204 | + if (isset($this->_fields[$key])) |
|
| 205 | + { |
|
| 206 | + return array( |
|
| 207 | + 'name' => $key, |
|
| 208 | + 'value' => $this->_fields[$key], |
|
| 209 | + 'boost' => $this->getFieldBoost($key) |
|
| 210 | + ); |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - return false; |
|
| 214 | - } |
|
| 213 | + return false; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - /** |
|
| 217 | - * Set a field value. Multi-valued fields should be set as arrays |
|
| 218 | - * or instead use the addField(...) function which will automatically |
|
| 219 | - * make sure the field is an array. |
|
| 220 | - * |
|
| 221 | - * @param string $key |
|
| 222 | - * @param mixed $value |
|
| 223 | - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 224 | - */ |
|
| 225 | - public function setField($key, $value, $boost = false) |
|
| 226 | - { |
|
| 227 | - $this->_fields[$key] = $value; |
|
| 228 | - $this->setFieldBoost($key, $boost); |
|
| 229 | - } |
|
| 216 | + /** |
|
| 217 | + * Set a field value. Multi-valued fields should be set as arrays |
|
| 218 | + * or instead use the addField(...) function which will automatically |
|
| 219 | + * make sure the field is an array. |
|
| 220 | + * |
|
| 221 | + * @param string $key |
|
| 222 | + * @param mixed $value |
|
| 223 | + * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 224 | + */ |
|
| 225 | + public function setField($key, $value, $boost = false) |
|
| 226 | + { |
|
| 227 | + $this->_fields[$key] = $value; |
|
| 228 | + $this->setFieldBoost($key, $boost); |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - /** |
|
| 232 | - * Get the currently set field boost for a document field |
|
| 233 | - * |
|
| 234 | - * @param string $key |
|
| 235 | - * @return float currently set field boost, false if one is not set |
|
| 236 | - */ |
|
| 237 | - public function getFieldBoost($key) |
|
| 238 | - { |
|
| 239 | - return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : false; |
|
| 240 | - } |
|
| 231 | + /** |
|
| 232 | + * Get the currently set field boost for a document field |
|
| 233 | + * |
|
| 234 | + * @param string $key |
|
| 235 | + * @return float currently set field boost, false if one is not set |
|
| 236 | + */ |
|
| 237 | + public function getFieldBoost($key) |
|
| 238 | + { |
|
| 239 | + return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : false; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - /** |
|
| 243 | - * Set the field boost for a document field |
|
| 244 | - * |
|
| 245 | - * @param string $key field name for the boost |
|
| 246 | - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 247 | - */ |
|
| 248 | - public function setFieldBoost($key, $boost) |
|
| 249 | - { |
|
| 250 | - $boost = (float) $boost; |
|
| 242 | + /** |
|
| 243 | + * Set the field boost for a document field |
|
| 244 | + * |
|
| 245 | + * @param string $key field name for the boost |
|
| 246 | + * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
|
| 247 | + */ |
|
| 248 | + public function setFieldBoost($key, $boost) |
|
| 249 | + { |
|
| 250 | + $boost = (float) $boost; |
|
| 251 | 251 | |
| 252 | - if ($boost > 0.0) |
|
| 253 | - { |
|
| 254 | - $this->_fieldBoosts[$key] = $boost; |
|
| 255 | - } |
|
| 256 | - else |
|
| 257 | - { |
|
| 258 | - $this->_fieldBoosts[$key] = false; |
|
| 259 | - } |
|
| 260 | - } |
|
| 252 | + if ($boost > 0.0) |
|
| 253 | + { |
|
| 254 | + $this->_fieldBoosts[$key] = $boost; |
|
| 255 | + } |
|
| 256 | + else |
|
| 257 | + { |
|
| 258 | + $this->_fieldBoosts[$key] = false; |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * Return current field boosts, indexed by field name |
|
| 264 | - * |
|
| 265 | - * @return array |
|
| 266 | - */ |
|
| 267 | - public function getFieldBoosts() |
|
| 268 | - { |
|
| 269 | - return $this->_fieldBoosts; |
|
| 270 | - } |
|
| 262 | + /** |
|
| 263 | + * Return current field boosts, indexed by field name |
|
| 264 | + * |
|
| 265 | + * @return array |
|
| 266 | + */ |
|
| 267 | + public function getFieldBoosts() |
|
| 268 | + { |
|
| 269 | + return $this->_fieldBoosts; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * Get the names of all fields in this document |
|
| 274 | - * |
|
| 275 | - * @return array |
|
| 276 | - */ |
|
| 277 | - public function getFieldNames() |
|
| 278 | - { |
|
| 279 | - return array_keys($this->_fields); |
|
| 280 | - } |
|
| 272 | + /** |
|
| 273 | + * Get the names of all fields in this document |
|
| 274 | + * |
|
| 275 | + * @return array |
|
| 276 | + */ |
|
| 277 | + public function getFieldNames() |
|
| 278 | + { |
|
| 279 | + return array_keys($this->_fields); |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - /** |
|
| 283 | - * Get the values of all fields in this document |
|
| 284 | - * |
|
| 285 | - * @return array |
|
| 286 | - */ |
|
| 287 | - public function getFieldValues() |
|
| 288 | - { |
|
| 289 | - return array_values($this->_fields); |
|
| 290 | - } |
|
| 282 | + /** |
|
| 283 | + * Get the values of all fields in this document |
|
| 284 | + * |
|
| 285 | + * @return array |
|
| 286 | + */ |
|
| 287 | + public function getFieldValues() |
|
| 288 | + { |
|
| 289 | + return array_values($this->_fields); |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - /** |
|
| 293 | - * IteratorAggregate implementation function. Allows usage: |
|
| 294 | - * |
|
| 295 | - * <code> |
|
| 296 | - * foreach ($document as $key => $value) |
|
| 297 | - * { |
|
| 298 | - * ... |
|
| 299 | - * } |
|
| 300 | - * </code> |
|
| 301 | - */ |
|
| 302 | - public function getIterator() |
|
| 303 | - { |
|
| 304 | - $arrayObject = new ArrayObject($this->_fields); |
|
| 292 | + /** |
|
| 293 | + * IteratorAggregate implementation function. Allows usage: |
|
| 294 | + * |
|
| 295 | + * <code> |
|
| 296 | + * foreach ($document as $key => $value) |
|
| 297 | + * { |
|
| 298 | + * ... |
|
| 299 | + * } |
|
| 300 | + * </code> |
|
| 301 | + */ |
|
| 302 | + public function getIterator() |
|
| 303 | + { |
|
| 304 | + $arrayObject = new ArrayObject($this->_fields); |
|
| 305 | 305 | |
| 306 | - return $arrayObject->getIterator(); |
|
| 307 | - } |
|
| 306 | + return $arrayObject->getIterator(); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - /** |
|
| 310 | - * Magic get for field values |
|
| 311 | - * |
|
| 312 | - * @param string $key |
|
| 313 | - * @return mixed |
|
| 314 | - */ |
|
| 315 | - public function __get($key) |
|
| 316 | - { |
|
| 317 | - if (isset($this->_fields[$key])) |
|
| 318 | - { |
|
| 319 | - return $this->_fields[$key]; |
|
| 320 | - } |
|
| 309 | + /** |
|
| 310 | + * Magic get for field values |
|
| 311 | + * |
|
| 312 | + * @param string $key |
|
| 313 | + * @return mixed |
|
| 314 | + */ |
|
| 315 | + public function __get($key) |
|
| 316 | + { |
|
| 317 | + if (isset($this->_fields[$key])) |
|
| 318 | + { |
|
| 319 | + return $this->_fields[$key]; |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - return null; |
|
| 323 | - } |
|
| 322 | + return null; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - /** |
|
| 326 | - * Magic set for field values. Multi-valued fields should be set as arrays |
|
| 327 | - * or instead use the addField(...) function which will automatically |
|
| 328 | - * make sure the field is an array. |
|
| 329 | - * |
|
| 330 | - * @param string $key |
|
| 331 | - * @param mixed $value |
|
| 332 | - */ |
|
| 333 | - public function __set($key, $value) |
|
| 334 | - { |
|
| 335 | - $this->setField($key, $value); |
|
| 336 | - } |
|
| 325 | + /** |
|
| 326 | + * Magic set for field values. Multi-valued fields should be set as arrays |
|
| 327 | + * or instead use the addField(...) function which will automatically |
|
| 328 | + * make sure the field is an array. |
|
| 329 | + * |
|
| 330 | + * @param string $key |
|
| 331 | + * @param mixed $value |
|
| 332 | + */ |
|
| 333 | + public function __set($key, $value) |
|
| 334 | + { |
|
| 335 | + $this->setField($key, $value); |
|
| 336 | + } |
|
| 337 | 337 | |
| 338 | - /** |
|
| 339 | - * Magic isset for fields values. Do not call directly. Allows usage: |
|
| 340 | - * |
|
| 341 | - * <code> |
|
| 342 | - * isset($document->some_field); |
|
| 343 | - * </code> |
|
| 344 | - * |
|
| 345 | - * @param string $key |
|
| 346 | - * @return boolean |
|
| 347 | - */ |
|
| 348 | - public function __isset($key) |
|
| 349 | - { |
|
| 350 | - return isset($this->_fields[$key]); |
|
| 351 | - } |
|
| 338 | + /** |
|
| 339 | + * Magic isset for fields values. Do not call directly. Allows usage: |
|
| 340 | + * |
|
| 341 | + * <code> |
|
| 342 | + * isset($document->some_field); |
|
| 343 | + * </code> |
|
| 344 | + * |
|
| 345 | + * @param string $key |
|
| 346 | + * @return boolean |
|
| 347 | + */ |
|
| 348 | + public function __isset($key) |
|
| 349 | + { |
|
| 350 | + return isset($this->_fields[$key]); |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | - /** |
|
| 354 | - * Magic unset for field values. Do not call directly. Allows usage: |
|
| 355 | - * |
|
| 356 | - * <code> |
|
| 357 | - * unset($document->some_field); |
|
| 358 | - * </code> |
|
| 359 | - * |
|
| 360 | - * @param string $key |
|
| 361 | - */ |
|
| 362 | - public function __unset($key) |
|
| 363 | - { |
|
| 364 | - unset($this->_fields[$key]); |
|
| 365 | - unset($this->_fieldBoosts[$key]); |
|
| 366 | - } |
|
| 353 | + /** |
|
| 354 | + * Magic unset for field values. Do not call directly. Allows usage: |
|
| 355 | + * |
|
| 356 | + * <code> |
|
| 357 | + * unset($document->some_field); |
|
| 358 | + * </code> |
|
| 359 | + * |
|
| 360 | + * @param string $key |
|
| 361 | + */ |
|
| 362 | + public function __unset($key) |
|
| 363 | + { |
|
| 364 | + unset($this->_fields[$key]); |
|
| 365 | + unset($this->_fieldBoosts[$key]); |
|
| 366 | + } |
|
| 367 | 367 | } |
| 368 | 368 | \ No newline at end of file |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @var array |
| 81 | 81 | */ |
| 82 | - protected $_fields = array(); |
|
| 82 | + protected $_fields = array (); |
|
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Document field boost values, indexed by name |
| 86 | 86 | * |
| 87 | 87 | * @var array array of floats |
| 88 | 88 | */ |
| 89 | - protected $_fieldBoosts = array(); |
|
| 89 | + protected $_fieldBoosts = array (); |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * Clear all boosts and fields from this document |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | $this->_documentBoost = false; |
| 97 | 97 | |
| 98 | - $this->_fields = array(); |
|
| 99 | - $this->_fieldBoosts = array(); |
|
| 98 | + $this->_fields = array (); |
|
| 99 | + $this->_fieldBoosts = array (); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -156,12 +156,12 @@ discard block |
||
| 156 | 156 | if (!isset($this->_fields[$key])) |
| 157 | 157 | { |
| 158 | 158 | // create holding array if this is the first value |
| 159 | - $this->_fields[$key] = array(); |
|
| 159 | + $this->_fields[$key] = array (); |
|
| 160 | 160 | } |
| 161 | 161 | else if (!is_array($this->_fields[$key])) |
| 162 | 162 | { |
| 163 | 163 | // move existing value into array if it is not already an array |
| 164 | - $this->_fields[$key] = array($this->_fields[$key]); |
|
| 164 | + $this->_fields[$key] = array ($this->_fields[$key]); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | if ($this->getFieldBoost($key) === false) |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | { |
| 204 | 204 | if (isset($this->_fields[$key])) |
| 205 | 205 | { |
| 206 | - return array( |
|
| 206 | + return array ( |
|
| 207 | 207 | 'name' => $key, |
| 208 | 208 | 'value' => $this->_fields[$key], |
| 209 | 209 | 'boost' => $this->getFieldBoost($key) |
@@ -55,8 +55,7 @@ discard block |
||
| 55 | 55 | * } |
| 56 | 56 | * </code> |
| 57 | 57 | */ |
| 58 | -class Apache_Solr_Document implements IteratorAggregate |
|
| 59 | -{ |
|
| 58 | +class Apache_Solr_Document implements IteratorAggregate { |
|
| 60 | 59 | /** |
| 61 | 60 | * SVN Revision meta data for this class |
| 62 | 61 | */ |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | /** |
| 92 | 91 | * Clear all boosts and fields from this document |
| 93 | 92 | */ |
| 94 | - public function clear() |
|
| 95 | - { |
|
| 93 | + public function clear() { |
|
| 96 | 94 | $this->_documentBoost = false; |
| 97 | 95 | |
| 98 | 96 | $this->_fields = array(); |
@@ -104,8 +102,7 @@ discard block |
||
| 104 | 102 | * |
| 105 | 103 | * @return mixed will be false for default, or else a float |
| 106 | 104 | */ |
| 107 | - public function getBoost() |
|
| 108 | - { |
|
| 105 | + public function getBoost() { |
|
| 109 | 106 | return $this->_documentBoost; |
| 110 | 107 | } |
| 111 | 108 | |
@@ -114,16 +111,12 @@ discard block |
||
| 114 | 111 | * |
| 115 | 112 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
| 116 | 113 | */ |
| 117 | - public function setBoost($boost) |
|
| 118 | - { |
|
| 114 | + public function setBoost($boost) { |
|
| 119 | 115 | $boost = (float) $boost; |
| 120 | 116 | |
| 121 | - if ($boost > 0.0) |
|
| 122 | - { |
|
| 117 | + if ($boost > 0.0) { |
|
| 123 | 118 | $this->_documentBoost = $boost; |
| 124 | - } |
|
| 125 | - else |
|
| 126 | - { |
|
| 119 | + } else { |
|
| 127 | 120 | $this->_documentBoost = false; |
| 128 | 121 | } |
| 129 | 122 | } |
@@ -151,26 +144,19 @@ discard block |
||
| 151 | 144 | * @param mixed $value |
| 152 | 145 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
| 153 | 146 | */ |
| 154 | - public function addField($key, $value, $boost = false) |
|
| 155 | - { |
|
| 156 | - if (!isset($this->_fields[$key])) |
|
| 157 | - { |
|
| 147 | + public function addField($key, $value, $boost = false) { |
|
| 148 | + if (!isset($this->_fields[$key])) { |
|
| 158 | 149 | // create holding array if this is the first value |
| 159 | 150 | $this->_fields[$key] = array(); |
| 160 | - } |
|
| 161 | - else if (!is_array($this->_fields[$key])) |
|
| 162 | - { |
|
| 151 | + } else if (!is_array($this->_fields[$key])) { |
|
| 163 | 152 | // move existing value into array if it is not already an array |
| 164 | 153 | $this->_fields[$key] = array($this->_fields[$key]); |
| 165 | 154 | } |
| 166 | 155 | |
| 167 | - if ($this->getFieldBoost($key) === false) |
|
| 168 | - { |
|
| 156 | + if ($this->getFieldBoost($key) === false) { |
|
| 169 | 157 | // boost not already set, set it now |
| 170 | 158 | $this->setFieldBoost($key, $boost); |
| 171 | - } |
|
| 172 | - else if ((float) $boost > 0.0) |
|
| 173 | - { |
|
| 159 | + } else if ((float) $boost > 0.0) { |
|
| 174 | 160 | // multiply passed boost with current field boost - similar to SolrJ implementation |
| 175 | 161 | $this->_fieldBoosts[$key] *= (float) $boost; |
| 176 | 162 | } |
@@ -188,8 +174,7 @@ discard block |
||
| 188 | 174 | * |
| 189 | 175 | * @deprecated Use addField(...) instead |
| 190 | 176 | */ |
| 191 | - public function setMultiValue($key, $value, $boost = false) |
|
| 192 | - { |
|
| 177 | + public function setMultiValue($key, $value, $boost = false) { |
|
| 193 | 178 | $this->addField($key, $value, $boost); |
| 194 | 179 | } |
| 195 | 180 | |
@@ -199,10 +184,8 @@ discard block |
||
| 199 | 184 | * @param string $key |
| 200 | 185 | * @return mixed associative array of info if field exists, false otherwise |
| 201 | 186 | */ |
| 202 | - public function getField($key) |
|
| 203 | - { |
|
| 204 | - if (isset($this->_fields[$key])) |
|
| 205 | - { |
|
| 187 | + public function getField($key) { |
|
| 188 | + if (isset($this->_fields[$key])) { |
|
| 206 | 189 | return array( |
| 207 | 190 | 'name' => $key, |
| 208 | 191 | 'value' => $this->_fields[$key], |
@@ -222,8 +205,7 @@ discard block |
||
| 222 | 205 | * @param mixed $value |
| 223 | 206 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
| 224 | 207 | */ |
| 225 | - public function setField($key, $value, $boost = false) |
|
| 226 | - { |
|
| 208 | + public function setField($key, $value, $boost = false) { |
|
| 227 | 209 | $this->_fields[$key] = $value; |
| 228 | 210 | $this->setFieldBoost($key, $boost); |
| 229 | 211 | } |
@@ -234,8 +216,7 @@ discard block |
||
| 234 | 216 | * @param string $key |
| 235 | 217 | * @return float currently set field boost, false if one is not set |
| 236 | 218 | */ |
| 237 | - public function getFieldBoost($key) |
|
| 238 | - { |
|
| 219 | + public function getFieldBoost($key) { |
|
| 239 | 220 | return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : false; |
| 240 | 221 | } |
| 241 | 222 | |
@@ -245,16 +226,12 @@ discard block |
||
| 245 | 226 | * @param string $key field name for the boost |
| 246 | 227 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
| 247 | 228 | */ |
| 248 | - public function setFieldBoost($key, $boost) |
|
| 249 | - { |
|
| 229 | + public function setFieldBoost($key, $boost) { |
|
| 250 | 230 | $boost = (float) $boost; |
| 251 | 231 | |
| 252 | - if ($boost > 0.0) |
|
| 253 | - { |
|
| 232 | + if ($boost > 0.0) { |
|
| 254 | 233 | $this->_fieldBoosts[$key] = $boost; |
| 255 | - } |
|
| 256 | - else |
|
| 257 | - { |
|
| 234 | + } else { |
|
| 258 | 235 | $this->_fieldBoosts[$key] = false; |
| 259 | 236 | } |
| 260 | 237 | } |
@@ -264,8 +241,7 @@ discard block |
||
| 264 | 241 | * |
| 265 | 242 | * @return array |
| 266 | 243 | */ |
| 267 | - public function getFieldBoosts() |
|
| 268 | - { |
|
| 244 | + public function getFieldBoosts() { |
|
| 269 | 245 | return $this->_fieldBoosts; |
| 270 | 246 | } |
| 271 | 247 | |
@@ -274,8 +250,7 @@ discard block |
||
| 274 | 250 | * |
| 275 | 251 | * @return array |
| 276 | 252 | */ |
| 277 | - public function getFieldNames() |
|
| 278 | - { |
|
| 253 | + public function getFieldNames() { |
|
| 279 | 254 | return array_keys($this->_fields); |
| 280 | 255 | } |
| 281 | 256 | |
@@ -284,8 +259,7 @@ discard block |
||
| 284 | 259 | * |
| 285 | 260 | * @return array |
| 286 | 261 | */ |
| 287 | - public function getFieldValues() |
|
| 288 | - { |
|
| 262 | + public function getFieldValues() { |
|
| 289 | 263 | return array_values($this->_fields); |
| 290 | 264 | } |
| 291 | 265 | |
@@ -299,8 +273,7 @@ discard block |
||
| 299 | 273 | * } |
| 300 | 274 | * </code> |
| 301 | 275 | */ |
| 302 | - public function getIterator() |
|
| 303 | - { |
|
| 276 | + public function getIterator() { |
|
| 304 | 277 | $arrayObject = new ArrayObject($this->_fields); |
| 305 | 278 | |
| 306 | 279 | return $arrayObject->getIterator(); |
@@ -312,10 +285,8 @@ discard block |
||
| 312 | 285 | * @param string $key |
| 313 | 286 | * @return mixed |
| 314 | 287 | */ |
| 315 | - public function __get($key) |
|
| 316 | - { |
|
| 317 | - if (isset($this->_fields[$key])) |
|
| 318 | - { |
|
| 288 | + public function __get($key) { |
|
| 289 | + if (isset($this->_fields[$key])) { |
|
| 319 | 290 | return $this->_fields[$key]; |
| 320 | 291 | } |
| 321 | 292 | |
@@ -330,8 +301,7 @@ discard block |
||
| 330 | 301 | * @param string $key |
| 331 | 302 | * @param mixed $value |
| 332 | 303 | */ |
| 333 | - public function __set($key, $value) |
|
| 334 | - { |
|
| 304 | + public function __set($key, $value) { |
|
| 335 | 305 | $this->setField($key, $value); |
| 336 | 306 | } |
| 337 | 307 | |
@@ -345,8 +315,7 @@ discard block |
||
| 345 | 315 | * @param string $key |
| 346 | 316 | * @return boolean |
| 347 | 317 | */ |
| 348 | - public function __isset($key) |
|
| 349 | - { |
|
| 318 | + public function __isset($key) { |
|
| 350 | 319 | return isset($this->_fields[$key]); |
| 351 | 320 | } |
| 352 | 321 | |
@@ -359,8 +328,7 @@ discard block |
||
| 359 | 328 | * |
| 360 | 329 | * @param string $key |
| 361 | 330 | */ |
| 362 | - public function __unset($key) |
|
| 363 | - { |
|
| 331 | + public function __unset($key) { |
|
| 364 | 332 | unset($this->_fields[$key]); |
| 365 | 333 | unset($this->_fieldBoosts[$key]); |
| 366 | 334 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @var float |
| 74 | 74 | */ |
| 75 | - protected $_documentBoost = false; |
|
| 75 | + protected $_documentBoost = FALSE; |
|
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * Document field values, indexed by name |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function clear() |
| 95 | 95 | { |
| 96 | - $this->_documentBoost = false; |
|
| 96 | + $this->_documentBoost = FALSE; |
|
| 97 | 97 | |
| 98 | 98 | $this->_fields = array(); |
| 99 | 99 | $this->_fieldBoosts = array(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | else |
| 126 | 126 | { |
| 127 | - $this->_documentBoost = false; |
|
| 127 | + $this->_documentBoost = FALSE; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @param mixed $value |
| 152 | 152 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
| 153 | 153 | */ |
| 154 | - public function addField($key, $value, $boost = false) |
|
| 154 | + public function addField($key, $value, $boost = FALSE) |
|
| 155 | 155 | { |
| 156 | 156 | if (!isset($this->_fields[$key])) |
| 157 | 157 | { |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $this->_fields[$key] = array($this->_fields[$key]); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ($this->getFieldBoost($key) === false) |
|
| 167 | + if ($this->getFieldBoost($key) === FALSE) |
|
| 168 | 168 | { |
| 169 | 169 | // boost not already set, set it now |
| 170 | 170 | $this->setFieldBoost($key, $boost); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @deprecated Use addField(...) instead |
| 190 | 190 | */ |
| 191 | - public function setMultiValue($key, $value, $boost = false) |
|
| 191 | + public function setMultiValue($key, $value, $boost = FALSE) |
|
| 192 | 192 | { |
| 193 | 193 | $this->addField($key, $value, $boost); |
| 194 | 194 | } |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | ); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - return false; |
|
| 213 | + return FALSE; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * @param mixed $value |
| 223 | 223 | * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false |
| 224 | 224 | */ |
| 225 | - public function setField($key, $value, $boost = false) |
|
| 225 | + public function setField($key, $value, $boost = FALSE) |
|
| 226 | 226 | { |
| 227 | 227 | $this->_fields[$key] = $value; |
| 228 | 228 | $this->setFieldBoost($key, $boost); |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | */ |
| 237 | 237 | public function getFieldBoost($key) |
| 238 | 238 | { |
| 239 | - return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : false; |
|
| 239 | + return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : FALSE; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | } |
| 256 | 256 | else |
| 257 | 257 | { |
| 258 | - $this->_fieldBoosts[$key] = false; |
|
| 258 | + $this->_fieldBoosts[$key] = FALSE; |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | return $this->_fields[$key]; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - return null; |
|
| 322 | + return NULL; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | /** |
@@ -38,13 +38,13 @@ |
||
| 38 | 38 | |
| 39 | 39 | class Apache_Solr_InvalidArgumentException extends Apache_Solr_Exception |
| 40 | 40 | { |
| 41 | - /** |
|
| 42 | - * SVN Revision meta data for this class |
|
| 43 | - */ |
|
| 44 | - const SVN_REVISION = '$Revision: 54 $'; |
|
| 41 | + /** |
|
| 42 | + * SVN Revision meta data for this class |
|
| 43 | + */ |
|
| 44 | + const SVN_REVISION = '$Revision: 54 $'; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * SVN ID meta data for this class |
|
| 48 | - */ |
|
| 49 | - const SVN_ID = '$Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; |
|
| 46 | + /** |
|
| 47 | + * SVN ID meta data for this class |
|
| 48 | + */ |
|
| 49 | + const SVN_ID = '$Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; |
|
| 50 | 50 | } |
| 51 | 51 | \ No newline at end of file |
@@ -36,8 +36,7 @@ |
||
| 36 | 36 | * @author Donovan Jimenez <[email protected]> |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | -class Apache_Solr_InvalidArgumentException extends Apache_Solr_Exception |
|
| 40 | -{ |
|
| 39 | +class Apache_Solr_InvalidArgumentException extends Apache_Solr_Exception { |
|
| 41 | 40 | /** |
| 42 | 41 | * SVN Revision meta data for this class |
| 43 | 42 | */ |
@@ -44,173 +44,173 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | class Apache_Solr_HttpTransport_FileGetContents extends Apache_Solr_HttpTransport_Abstract |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * SVN Revision meta data for this class |
|
| 49 | - */ |
|
| 50 | - const SVN_REVISION = '$Revision: $'; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * SVN ID meta data for this class |
|
| 54 | - */ |
|
| 55 | - const SVN_ID = '$Id: $'; |
|
| 47 | + /** |
|
| 48 | + * SVN Revision meta data for this class |
|
| 49 | + */ |
|
| 50 | + const SVN_REVISION = '$Revision: $'; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * SVN ID meta data for this class |
|
| 54 | + */ |
|
| 55 | + const SVN_ID = '$Id: $'; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Reusable stream context resources for GET and POST operations |
|
| 59 | - * |
|
| 60 | - * @var resource |
|
| 61 | - */ |
|
| 62 | - private $_getContext, $_headContext, $_postContext; |
|
| 57 | + /** |
|
| 58 | + * Reusable stream context resources for GET and POST operations |
|
| 59 | + * |
|
| 60 | + * @var resource |
|
| 61 | + */ |
|
| 62 | + private $_getContext, $_headContext, $_postContext; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Initializes our reuseable get and post stream contexts |
|
| 66 | - */ |
|
| 67 | - public function __construct() |
|
| 68 | - { |
|
| 69 | - $this->_getContext = stream_context_create(); |
|
| 70 | - $this->_headContext = stream_context_create(); |
|
| 71 | - $this->_postContext = stream_context_create(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function performGetRequest($url, $timeout = false) |
|
| 75 | - { |
|
| 76 | - // set the timeout if specified |
|
| 77 | - if ($timeout !== FALSE && $timeout > 0.0) |
|
| 78 | - { |
|
| 79 | - // timeouts with file_get_contents seem to need |
|
| 80 | - // to be halved to work as expected |
|
| 81 | - $timeout = (float) $timeout / 2; |
|
| 82 | - |
|
| 83 | - stream_context_set_option($this->_getContext, 'http', 'timeout', $timeout); |
|
| 84 | - } |
|
| 85 | - else |
|
| 86 | - { |
|
| 87 | - // use the default timeout pulled from default_socket_timeout otherwise |
|
| 88 | - stream_context_set_option($this->_getContext, 'http', 'timeout', $this->getDefaultTimeout()); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // $http_response_headers will be updated by the call to file_get_contents later |
|
| 92 | - // see http://us.php.net/manual/en/wrappers.http.php for documentation |
|
| 93 | - // Unfortunately, it will still create a notice in analyzers if we don't set it here |
|
| 94 | - $http_response_header = null; |
|
| 95 | - $responseBody = @file_get_contents($url, false, $this->_getContext); |
|
| 64 | + /** |
|
| 65 | + * Initializes our reuseable get and post stream contexts |
|
| 66 | + */ |
|
| 67 | + public function __construct() |
|
| 68 | + { |
|
| 69 | + $this->_getContext = stream_context_create(); |
|
| 70 | + $this->_headContext = stream_context_create(); |
|
| 71 | + $this->_postContext = stream_context_create(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function performGetRequest($url, $timeout = false) |
|
| 75 | + { |
|
| 76 | + // set the timeout if specified |
|
| 77 | + if ($timeout !== FALSE && $timeout > 0.0) |
|
| 78 | + { |
|
| 79 | + // timeouts with file_get_contents seem to need |
|
| 80 | + // to be halved to work as expected |
|
| 81 | + $timeout = (float) $timeout / 2; |
|
| 82 | + |
|
| 83 | + stream_context_set_option($this->_getContext, 'http', 'timeout', $timeout); |
|
| 84 | + } |
|
| 85 | + else |
|
| 86 | + { |
|
| 87 | + // use the default timeout pulled from default_socket_timeout otherwise |
|
| 88 | + stream_context_set_option($this->_getContext, 'http', 'timeout', $this->getDefaultTimeout()); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // $http_response_headers will be updated by the call to file_get_contents later |
|
| 92 | + // see http://us.php.net/manual/en/wrappers.http.php for documentation |
|
| 93 | + // Unfortunately, it will still create a notice in analyzers if we don't set it here |
|
| 94 | + $http_response_header = null; |
|
| 95 | + $responseBody = @file_get_contents($url, false, $this->_getContext); |
|
| 96 | 96 | |
| 97 | - return $this->_getResponseFromParts($responseBody, $http_response_header); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - public function performHeadRequest($url, $timeout = false) |
|
| 101 | - { |
|
| 102 | - stream_context_set_option($this->_headContext, array( |
|
| 103 | - 'http' => array( |
|
| 104 | - // set HTTP method |
|
| 105 | - 'method' => 'HEAD', |
|
| 106 | - |
|
| 107 | - // default timeout |
|
| 108 | - 'timeout' => $this->getDefaultTimeout() |
|
| 109 | - ) |
|
| 110 | - ) |
|
| 111 | - ); |
|
| 112 | - |
|
| 113 | - // set the timeout if specified |
|
| 114 | - if ($timeout !== FALSE && $timeout > 0.0) |
|
| 115 | - { |
|
| 116 | - // timeouts with file_get_contents seem to need |
|
| 117 | - // to be halved to work as expected |
|
| 118 | - $timeout = (float) $timeout / 2; |
|
| 119 | - |
|
| 120 | - stream_context_set_option($this->_headContext, 'http', 'timeout', $timeout); |
|
| 121 | - } |
|
| 97 | + return $this->_getResponseFromParts($responseBody, $http_response_header); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + public function performHeadRequest($url, $timeout = false) |
|
| 101 | + { |
|
| 102 | + stream_context_set_option($this->_headContext, array( |
|
| 103 | + 'http' => array( |
|
| 104 | + // set HTTP method |
|
| 105 | + 'method' => 'HEAD', |
|
| 106 | + |
|
| 107 | + // default timeout |
|
| 108 | + 'timeout' => $this->getDefaultTimeout() |
|
| 109 | + ) |
|
| 110 | + ) |
|
| 111 | + ); |
|
| 112 | + |
|
| 113 | + // set the timeout if specified |
|
| 114 | + if ($timeout !== FALSE && $timeout > 0.0) |
|
| 115 | + { |
|
| 116 | + // timeouts with file_get_contents seem to need |
|
| 117 | + // to be halved to work as expected |
|
| 118 | + $timeout = (float) $timeout / 2; |
|
| 119 | + |
|
| 120 | + stream_context_set_option($this->_headContext, 'http', 'timeout', $timeout); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - // $http_response_headers will be updated by the call to file_get_contents later |
|
| 124 | - // see http://us.php.net/manual/en/wrappers.http.php for documentation |
|
| 125 | - // Unfortunately, it will still create a notice in analyzers if we don't set it here |
|
| 126 | - $http_response_header = null; |
|
| 127 | - $responseBody = @file_get_contents($url, false, $this->_headContext); |
|
| 128 | - |
|
| 129 | - return $this->_getResponseFromParts($responseBody, $http_response_header); |
|
| 130 | - } |
|
| 123 | + // $http_response_headers will be updated by the call to file_get_contents later |
|
| 124 | + // see http://us.php.net/manual/en/wrappers.http.php for documentation |
|
| 125 | + // Unfortunately, it will still create a notice in analyzers if we don't set it here |
|
| 126 | + $http_response_header = null; |
|
| 127 | + $responseBody = @file_get_contents($url, false, $this->_headContext); |
|
| 128 | + |
|
| 129 | + return $this->_getResponseFromParts($responseBody, $http_response_header); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - public function performPostRequest($url, $rawPost, $contentType, $timeout = false) |
|
| 133 | - { |
|
| 134 | - stream_context_set_option($this->_postContext, array( |
|
| 135 | - 'http' => array( |
|
| 136 | - // set HTTP method |
|
| 137 | - 'method' => 'POST', |
|
| 138 | - |
|
| 139 | - // Add our posted content type |
|
| 140 | - 'header' => "Content-Type: $contentType", |
|
| 141 | - |
|
| 142 | - // the posted content |
|
| 143 | - 'content' => $rawPost, |
|
| 144 | - |
|
| 145 | - // default timeout |
|
| 146 | - 'timeout' => $this->getDefaultTimeout() |
|
| 147 | - ) |
|
| 148 | - ) |
|
| 149 | - ); |
|
| 150 | - |
|
| 151 | - // set the timeout if specified |
|
| 152 | - if ($timeout !== FALSE && $timeout > 0.0) |
|
| 153 | - { |
|
| 154 | - // timeouts with file_get_contents seem to need |
|
| 155 | - // to be halved to work as expected |
|
| 156 | - $timeout = (float) $timeout / 2; |
|
| 157 | - |
|
| 158 | - stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // $http_response_header will be updated by the call to file_get_contents later |
|
| 162 | - // see http://us.php.net/manual/en/wrappers.http.php for documentation |
|
| 163 | - // Unfortunately, it will still create a notice in analyzers if we don't set it here |
|
| 164 | - $http_response_header = null; |
|
| 165 | - $responseBody = @file_get_contents($url, false, $this->_postContext); |
|
| 132 | + public function performPostRequest($url, $rawPost, $contentType, $timeout = false) |
|
| 133 | + { |
|
| 134 | + stream_context_set_option($this->_postContext, array( |
|
| 135 | + 'http' => array( |
|
| 136 | + // set HTTP method |
|
| 137 | + 'method' => 'POST', |
|
| 138 | + |
|
| 139 | + // Add our posted content type |
|
| 140 | + 'header' => "Content-Type: $contentType", |
|
| 141 | + |
|
| 142 | + // the posted content |
|
| 143 | + 'content' => $rawPost, |
|
| 144 | + |
|
| 145 | + // default timeout |
|
| 146 | + 'timeout' => $this->getDefaultTimeout() |
|
| 147 | + ) |
|
| 148 | + ) |
|
| 149 | + ); |
|
| 150 | + |
|
| 151 | + // set the timeout if specified |
|
| 152 | + if ($timeout !== FALSE && $timeout > 0.0) |
|
| 153 | + { |
|
| 154 | + // timeouts with file_get_contents seem to need |
|
| 155 | + // to be halved to work as expected |
|
| 156 | + $timeout = (float) $timeout / 2; |
|
| 157 | + |
|
| 158 | + stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // $http_response_header will be updated by the call to file_get_contents later |
|
| 162 | + // see http://us.php.net/manual/en/wrappers.http.php for documentation |
|
| 163 | + // Unfortunately, it will still create a notice in analyzers if we don't set it here |
|
| 164 | + $http_response_header = null; |
|
| 165 | + $responseBody = @file_get_contents($url, false, $this->_postContext); |
|
| 166 | 166 | |
| 167 | - // reset content of post context to reclaim memory |
|
| 168 | - stream_context_set_option($this->_postContext, 'http', 'content', ''); |
|
| 167 | + // reset content of post context to reclaim memory |
|
| 168 | + stream_context_set_option($this->_postContext, 'http', 'content', ''); |
|
| 169 | 169 | |
| 170 | - return $this->_getResponseFromParts($responseBody, $http_response_header); |
|
| 171 | - } |
|
| 170 | + return $this->_getResponseFromParts($responseBody, $http_response_header); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - private function _getResponseFromParts($rawResponse, $httpHeaders) |
|
| 174 | - { |
|
| 175 | - //Assume 0, false as defaults |
|
| 176 | - $status = 0; |
|
| 177 | - $contentType = false; |
|
| 178 | - |
|
| 179 | - //iterate through headers for real status, type, and encoding |
|
| 180 | - if (is_array($httpHeaders) && count($httpHeaders) > 0) |
|
| 181 | - { |
|
| 182 | - //look at the first headers for the HTTP status code |
|
| 183 | - //and message (errors are usually returned this way) |
|
| 184 | - // |
|
| 185 | - //HTTP 100 Continue response can also be returned before |
|
| 186 | - //the REAL status header, so we need look until we find |
|
| 187 | - //the last header starting with HTTP |
|
| 188 | - // |
|
| 189 | - //the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1 |
|
| 190 | - // |
|
| 191 | - //Thanks to Daniel Andersson for pointing out this oversight |
|
| 192 | - while (isset($httpHeaders[0]) && substr($httpHeaders[0], 0, 4) == 'HTTP') |
|
| 193 | - { |
|
| 194 | - // we can do a intval on status line without the "HTTP/1.X " to get the code |
|
| 195 | - $status = intval(substr($httpHeaders[0], 9)); |
|
| 196 | - |
|
| 197 | - // remove this from the headers so we can check for more |
|
| 198 | - array_shift($httpHeaders); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - //Look for the Content-Type response header and determine type |
|
| 202 | - //and encoding from it (if possible - such as 'Content-Type: text/plain; charset=UTF-8') |
|
| 203 | - foreach ($httpHeaders as $header) |
|
| 204 | - { |
|
| 205 | - // look for the header that starts appropriately |
|
| 206 | - if (strncasecmp($header, 'Content-Type:', 13) == 0) |
|
| 207 | - { |
|
| 208 | - $contentType = substr($header, 13); |
|
| 209 | - break; |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - } |
|
| 173 | + private function _getResponseFromParts($rawResponse, $httpHeaders) |
|
| 174 | + { |
|
| 175 | + //Assume 0, false as defaults |
|
| 176 | + $status = 0; |
|
| 177 | + $contentType = false; |
|
| 178 | + |
|
| 179 | + //iterate through headers for real status, type, and encoding |
|
| 180 | + if (is_array($httpHeaders) && count($httpHeaders) > 0) |
|
| 181 | + { |
|
| 182 | + //look at the first headers for the HTTP status code |
|
| 183 | + //and message (errors are usually returned this way) |
|
| 184 | + // |
|
| 185 | + //HTTP 100 Continue response can also be returned before |
|
| 186 | + //the REAL status header, so we need look until we find |
|
| 187 | + //the last header starting with HTTP |
|
| 188 | + // |
|
| 189 | + //the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1 |
|
| 190 | + // |
|
| 191 | + //Thanks to Daniel Andersson for pointing out this oversight |
|
| 192 | + while (isset($httpHeaders[0]) && substr($httpHeaders[0], 0, 4) == 'HTTP') |
|
| 193 | + { |
|
| 194 | + // we can do a intval on status line without the "HTTP/1.X " to get the code |
|
| 195 | + $status = intval(substr($httpHeaders[0], 9)); |
|
| 196 | + |
|
| 197 | + // remove this from the headers so we can check for more |
|
| 198 | + array_shift($httpHeaders); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + //Look for the Content-Type response header and determine type |
|
| 202 | + //and encoding from it (if possible - such as 'Content-Type: text/plain; charset=UTF-8') |
|
| 203 | + foreach ($httpHeaders as $header) |
|
| 204 | + { |
|
| 205 | + // look for the header that starts appropriately |
|
| 206 | + if (strncasecmp($header, 'Content-Type:', 13) == 0) |
|
| 207 | + { |
|
| 208 | + $contentType = substr($header, 13); |
|
| 209 | + break; |
|
| 210 | + } |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - return new Apache_Solr_HttpTransport_Response($status, $contentType, $rawResponse); |
|
| 215 | - } |
|
| 214 | + return new Apache_Solr_HttpTransport_Response($status, $contentType, $rawResponse); |
|
| 215 | + } |
|
| 216 | 216 | } |
| 217 | 217 | \ No newline at end of file |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | 39 | // Require Apache_Solr_HttpTransport_Abstract |
| 40 | -require_once(dirname(__FILE__) . '/Abstract.php'); |
|
| 40 | +require_once(dirname(__FILE__).'/Abstract.php'); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | public function performHeadRequest($url, $timeout = false) |
| 101 | 101 | { |
| 102 | - stream_context_set_option($this->_headContext, array( |
|
| 103 | - 'http' => array( |
|
| 102 | + stream_context_set_option($this->_headContext, array ( |
|
| 103 | + 'http' => array ( |
|
| 104 | 104 | // set HTTP method |
| 105 | 105 | 'method' => 'HEAD', |
| 106 | 106 | |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | public function performPostRequest($url, $rawPost, $contentType, $timeout = false) |
| 133 | 133 | { |
| 134 | - stream_context_set_option($this->_postContext, array( |
|
| 135 | - 'http' => array( |
|
| 134 | + stream_context_set_option($this->_postContext, array ( |
|
| 135 | + 'http' => array ( |
|
| 136 | 136 | // set HTTP method |
| 137 | 137 | 'method' => 'POST', |
| 138 | 138 | |
@@ -42,8 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents |
| 44 | 44 | */ |
| 45 | -class Apache_Solr_HttpTransport_FileGetContents extends Apache_Solr_HttpTransport_Abstract |
|
| 46 | -{ |
|
| 45 | +class Apache_Solr_HttpTransport_FileGetContents extends Apache_Solr_HttpTransport_Abstract { |
|
| 47 | 46 | /** |
| 48 | 47 | * SVN Revision meta data for this class |
| 49 | 48 | */ |
@@ -64,26 +63,21 @@ discard block |
||
| 64 | 63 | /** |
| 65 | 64 | * Initializes our reuseable get and post stream contexts |
| 66 | 65 | */ |
| 67 | - public function __construct() |
|
| 68 | - { |
|
| 66 | + public function __construct() { |
|
| 69 | 67 | $this->_getContext = stream_context_create(); |
| 70 | 68 | $this->_headContext = stream_context_create(); |
| 71 | 69 | $this->_postContext = stream_context_create(); |
| 72 | 70 | } |
| 73 | 71 | |
| 74 | - public function performGetRequest($url, $timeout = false) |
|
| 75 | - { |
|
| 72 | + public function performGetRequest($url, $timeout = false) { |
|
| 76 | 73 | // set the timeout if specified |
| 77 | - if ($timeout !== FALSE && $timeout > 0.0) |
|
| 78 | - { |
|
| 74 | + if ($timeout !== FALSE && $timeout > 0.0) { |
|
| 79 | 75 | // timeouts with file_get_contents seem to need |
| 80 | 76 | // to be halved to work as expected |
| 81 | 77 | $timeout = (float) $timeout / 2; |
| 82 | 78 | |
| 83 | 79 | stream_context_set_option($this->_getContext, 'http', 'timeout', $timeout); |
| 84 | - } |
|
| 85 | - else |
|
| 86 | - { |
|
| 80 | + } else { |
|
| 87 | 81 | // use the default timeout pulled from default_socket_timeout otherwise |
| 88 | 82 | stream_context_set_option($this->_getContext, 'http', 'timeout', $this->getDefaultTimeout()); |
| 89 | 83 | } |
@@ -97,8 +91,7 @@ discard block |
||
| 97 | 91 | return $this->_getResponseFromParts($responseBody, $http_response_header); |
| 98 | 92 | } |
| 99 | 93 | |
| 100 | - public function performHeadRequest($url, $timeout = false) |
|
| 101 | - { |
|
| 94 | + public function performHeadRequest($url, $timeout = false) { |
|
| 102 | 95 | stream_context_set_option($this->_headContext, array( |
| 103 | 96 | 'http' => array( |
| 104 | 97 | // set HTTP method |
@@ -111,8 +104,7 @@ discard block |
||
| 111 | 104 | ); |
| 112 | 105 | |
| 113 | 106 | // set the timeout if specified |
| 114 | - if ($timeout !== FALSE && $timeout > 0.0) |
|
| 115 | - { |
|
| 107 | + if ($timeout !== FALSE && $timeout > 0.0) { |
|
| 116 | 108 | // timeouts with file_get_contents seem to need |
| 117 | 109 | // to be halved to work as expected |
| 118 | 110 | $timeout = (float) $timeout / 2; |
@@ -129,8 +121,7 @@ discard block |
||
| 129 | 121 | return $this->_getResponseFromParts($responseBody, $http_response_header); |
| 130 | 122 | } |
| 131 | 123 | |
| 132 | - public function performPostRequest($url, $rawPost, $contentType, $timeout = false) |
|
| 133 | - { |
|
| 124 | + public function performPostRequest($url, $rawPost, $contentType, $timeout = false) { |
|
| 134 | 125 | stream_context_set_option($this->_postContext, array( |
| 135 | 126 | 'http' => array( |
| 136 | 127 | // set HTTP method |
@@ -149,8 +140,7 @@ discard block |
||
| 149 | 140 | ); |
| 150 | 141 | |
| 151 | 142 | // set the timeout if specified |
| 152 | - if ($timeout !== FALSE && $timeout > 0.0) |
|
| 153 | - { |
|
| 143 | + if ($timeout !== FALSE && $timeout > 0.0) { |
|
| 154 | 144 | // timeouts with file_get_contents seem to need |
| 155 | 145 | // to be halved to work as expected |
| 156 | 146 | $timeout = (float) $timeout / 2; |
@@ -170,15 +160,13 @@ discard block |
||
| 170 | 160 | return $this->_getResponseFromParts($responseBody, $http_response_header); |
| 171 | 161 | } |
| 172 | 162 | |
| 173 | - private function _getResponseFromParts($rawResponse, $httpHeaders) |
|
| 174 | - { |
|
| 163 | + private function _getResponseFromParts($rawResponse, $httpHeaders) { |
|
| 175 | 164 | //Assume 0, false as defaults |
| 176 | 165 | $status = 0; |
| 177 | 166 | $contentType = false; |
| 178 | 167 | |
| 179 | 168 | //iterate through headers for real status, type, and encoding |
| 180 | - if (is_array($httpHeaders) && count($httpHeaders) > 0) |
|
| 181 | - { |
|
| 169 | + if (is_array($httpHeaders) && count($httpHeaders) > 0) { |
|
| 182 | 170 | //look at the first headers for the HTTP status code |
| 183 | 171 | //and message (errors are usually returned this way) |
| 184 | 172 | // |
@@ -189,8 +177,7 @@ discard block |
||
| 189 | 177 | //the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1 |
| 190 | 178 | // |
| 191 | 179 | //Thanks to Daniel Andersson for pointing out this oversight |
| 192 | - while (isset($httpHeaders[0]) && substr($httpHeaders[0], 0, 4) == 'HTTP') |
|
| 193 | - { |
|
| 180 | + while (isset($httpHeaders[0]) && substr($httpHeaders[0], 0, 4) == 'HTTP') { |
|
| 194 | 181 | // we can do a intval on status line without the "HTTP/1.X " to get the code |
| 195 | 182 | $status = intval(substr($httpHeaders[0], 9)); |
| 196 | 183 | |
@@ -200,11 +187,9 @@ discard block |
||
| 200 | 187 | |
| 201 | 188 | //Look for the Content-Type response header and determine type |
| 202 | 189 | //and encoding from it (if possible - such as 'Content-Type: text/plain; charset=UTF-8') |
| 203 | - foreach ($httpHeaders as $header) |
|
| 204 | - { |
|
| 190 | + foreach ($httpHeaders as $header) { |
|
| 205 | 191 | // look for the header that starts appropriately |
| 206 | - if (strncasecmp($header, 'Content-Type:', 13) == 0) |
|
| 207 | - { |
|
| 192 | + if (strncasecmp($header, 'Content-Type:', 13) == 0) { |
|
| 208 | 193 | $contentType = substr($header, 13); |
| 209 | 194 | break; |
| 210 | 195 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $this->_postContext = stream_context_create(); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function performGetRequest($url, $timeout = false) |
|
| 74 | + public function performGetRequest($url, $timeout = FALSE) |
|
| 75 | 75 | { |
| 76 | 76 | // set the timeout if specified |
| 77 | 77 | if ($timeout !== FALSE && $timeout > 0.0) |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | // $http_response_headers will be updated by the call to file_get_contents later |
| 92 | 92 | // see http://us.php.net/manual/en/wrappers.http.php for documentation |
| 93 | 93 | // Unfortunately, it will still create a notice in analyzers if we don't set it here |
| 94 | - $http_response_header = null; |
|
| 95 | - $responseBody = @file_get_contents($url, false, $this->_getContext); |
|
| 94 | + $http_response_header = NULL; |
|
| 95 | + $responseBody = @file_get_contents($url, FALSE, $this->_getContext); |
|
| 96 | 96 | |
| 97 | 97 | return $this->_getResponseFromParts($responseBody, $http_response_header); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - public function performHeadRequest($url, $timeout = false) |
|
| 100 | + public function performHeadRequest($url, $timeout = FALSE) |
|
| 101 | 101 | { |
| 102 | 102 | stream_context_set_option($this->_headContext, array( |
| 103 | 103 | 'http' => array( |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | // $http_response_headers will be updated by the call to file_get_contents later |
| 124 | 124 | // see http://us.php.net/manual/en/wrappers.http.php for documentation |
| 125 | 125 | // Unfortunately, it will still create a notice in analyzers if we don't set it here |
| 126 | - $http_response_header = null; |
|
| 127 | - $responseBody = @file_get_contents($url, false, $this->_headContext); |
|
| 126 | + $http_response_header = NULL; |
|
| 127 | + $responseBody = @file_get_contents($url, FALSE, $this->_headContext); |
|
| 128 | 128 | |
| 129 | 129 | return $this->_getResponseFromParts($responseBody, $http_response_header); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public function performPostRequest($url, $rawPost, $contentType, $timeout = false) |
|
| 132 | + public function performPostRequest($url, $rawPost, $contentType, $timeout = FALSE) |
|
| 133 | 133 | { |
| 134 | 134 | stream_context_set_option($this->_postContext, array( |
| 135 | 135 | 'http' => array( |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | // $http_response_header will be updated by the call to file_get_contents later |
| 162 | 162 | // see http://us.php.net/manual/en/wrappers.http.php for documentation |
| 163 | 163 | // Unfortunately, it will still create a notice in analyzers if we don't set it here |
| 164 | - $http_response_header = null; |
|
| 165 | - $responseBody = @file_get_contents($url, false, $this->_postContext); |
|
| 164 | + $http_response_header = NULL; |
|
| 165 | + $responseBody = @file_get_contents($url, FALSE, $this->_postContext); |
|
| 166 | 166 | |
| 167 | 167 | // reset content of post context to reclaim memory |
| 168 | 168 | stream_context_set_option($this->_postContext, 'http', 'content', ''); |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | { |
| 175 | 175 | //Assume 0, false as defaults |
| 176 | 176 | $status = 0; |
| 177 | - $contentType = false; |
|
| 177 | + $contentType = FALSE; |
|
| 178 | 178 | |
| 179 | 179 | //iterate through headers for real status, type, and encoding |
| 180 | 180 | if (is_array($httpHeaders) && count($httpHeaders) > 0) |
@@ -44,155 +44,155 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | class Apache_Solr_HttpTransport_Curl extends Apache_Solr_HttpTransport_Abstract |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * SVN Revision meta data for this class |
|
| 49 | - */ |
|
| 50 | - const SVN_REVISION = '$Revision:$'; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * SVN ID meta data for this class |
|
| 54 | - */ |
|
| 55 | - const SVN_ID = '$Id:$'; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Curl Session Handle |
|
| 59 | - * |
|
| 60 | - * @var resource |
|
| 61 | - */ |
|
| 62 | - private $_curl; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Initializes a curl session |
|
| 66 | - */ |
|
| 67 | - public function __construct() |
|
| 68 | - { |
|
| 69 | - // initialize a CURL session |
|
| 70 | - $this->_curl = curl_init(); |
|
| 71 | - |
|
| 72 | - // set common options that will not be changed during the session |
|
| 73 | - curl_setopt_array($this->_curl, array( |
|
| 74 | - // return the response body from curl_exec |
|
| 75 | - CURLOPT_RETURNTRANSFER => true, |
|
| 76 | - |
|
| 77 | - // get the output as binary data |
|
| 78 | - CURLOPT_BINARYTRANSFER => true, |
|
| 79 | - |
|
| 80 | - // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 81 | - CURLOPT_HEADER => false |
|
| 82 | - )); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * Closes a curl session |
|
| 87 | - */ |
|
| 88 | - function __destruct() |
|
| 89 | - { |
|
| 90 | - // close our curl session |
|
| 91 | - curl_close($this->_curl); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - public function performGetRequest($url, $timeout = false) |
|
| 95 | - { |
|
| 96 | - // check the timeout value |
|
| 97 | - if ($timeout === false || $timeout <= 0.0) |
|
| 98 | - { |
|
| 99 | - // use the default timeout |
|
| 100 | - $timeout = $this->getDefaultTimeout(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // set curl GET options |
|
| 104 | - curl_setopt_array($this->_curl, array( |
|
| 105 | - // make sure we're returning the body |
|
| 106 | - CURLOPT_NOBODY => false, |
|
| 107 | - |
|
| 108 | - // make sure we're GET |
|
| 109 | - CURLOPT_HTTPGET => true, |
|
| 110 | - |
|
| 111 | - // set the URL |
|
| 112 | - CURLOPT_URL => $url, |
|
| 113 | - |
|
| 114 | - // set the timeout |
|
| 115 | - CURLOPT_TIMEOUT => $timeout |
|
| 116 | - )); |
|
| 117 | - |
|
| 118 | - // make the request |
|
| 119 | - $responseBody = curl_exec($this->_curl); |
|
| 120 | - |
|
| 121 | - // get info from the transfer |
|
| 122 | - $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); |
|
| 123 | - $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); |
|
| 124 | - |
|
| 125 | - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - public function performHeadRequest($url, $timeout = false) |
|
| 129 | - { |
|
| 130 | - // check the timeout value |
|
| 131 | - if ($timeout === false || $timeout <= 0.0) |
|
| 132 | - { |
|
| 133 | - // use the default timeout |
|
| 134 | - $timeout = $this->getDefaultTimeout(); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // set curl HEAD options |
|
| 138 | - curl_setopt_array($this->_curl, array( |
|
| 139 | - // this both sets the method to HEAD and says not to return a body |
|
| 140 | - CURLOPT_NOBODY => true, |
|
| 141 | - |
|
| 142 | - // set the URL |
|
| 143 | - CURLOPT_URL => $url, |
|
| 144 | - |
|
| 145 | - // set the timeout |
|
| 146 | - CURLOPT_TIMEOUT => $timeout |
|
| 147 | - )); |
|
| 148 | - |
|
| 149 | - // make the request |
|
| 150 | - $responseBody = curl_exec($this->_curl); |
|
| 151 | - |
|
| 152 | - // get info from the transfer |
|
| 153 | - $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); |
|
| 154 | - $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); |
|
| 155 | - |
|
| 156 | - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 160 | - { |
|
| 161 | - // check the timeout value |
|
| 162 | - if ($timeout === false || $timeout <= 0.0) |
|
| 163 | - { |
|
| 164 | - // use the default timeout |
|
| 165 | - $timeout = $this->getDefaultTimeout(); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - // set curl POST options |
|
| 169 | - curl_setopt_array($this->_curl, array( |
|
| 170 | - // make sure we're returning the body |
|
| 171 | - CURLOPT_NOBODY => false, |
|
| 172 | - |
|
| 173 | - // make sure we're POST |
|
| 174 | - CURLOPT_POST => true, |
|
| 175 | - |
|
| 176 | - // set the URL |
|
| 177 | - CURLOPT_URL => $url, |
|
| 178 | - |
|
| 179 | - // set the post data |
|
| 180 | - CURLOPT_POSTFIELDS => $postData, |
|
| 181 | - |
|
| 182 | - // set the content type |
|
| 183 | - CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), |
|
| 184 | - |
|
| 185 | - // set the timeout |
|
| 186 | - CURLOPT_TIMEOUT => $timeout |
|
| 187 | - )); |
|
| 188 | - |
|
| 189 | - // make the request |
|
| 190 | - $responseBody = curl_exec($this->_curl); |
|
| 191 | - |
|
| 192 | - // get info from the transfer |
|
| 193 | - $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); |
|
| 194 | - $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); |
|
| 195 | - |
|
| 196 | - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 197 | - } |
|
| 47 | + /** |
|
| 48 | + * SVN Revision meta data for this class |
|
| 49 | + */ |
|
| 50 | + const SVN_REVISION = '$Revision:$'; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * SVN ID meta data for this class |
|
| 54 | + */ |
|
| 55 | + const SVN_ID = '$Id:$'; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Curl Session Handle |
|
| 59 | + * |
|
| 60 | + * @var resource |
|
| 61 | + */ |
|
| 62 | + private $_curl; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Initializes a curl session |
|
| 66 | + */ |
|
| 67 | + public function __construct() |
|
| 68 | + { |
|
| 69 | + // initialize a CURL session |
|
| 70 | + $this->_curl = curl_init(); |
|
| 71 | + |
|
| 72 | + // set common options that will not be changed during the session |
|
| 73 | + curl_setopt_array($this->_curl, array( |
|
| 74 | + // return the response body from curl_exec |
|
| 75 | + CURLOPT_RETURNTRANSFER => true, |
|
| 76 | + |
|
| 77 | + // get the output as binary data |
|
| 78 | + CURLOPT_BINARYTRANSFER => true, |
|
| 79 | + |
|
| 80 | + // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 81 | + CURLOPT_HEADER => false |
|
| 82 | + )); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * Closes a curl session |
|
| 87 | + */ |
|
| 88 | + function __destruct() |
|
| 89 | + { |
|
| 90 | + // close our curl session |
|
| 91 | + curl_close($this->_curl); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + public function performGetRequest($url, $timeout = false) |
|
| 95 | + { |
|
| 96 | + // check the timeout value |
|
| 97 | + if ($timeout === false || $timeout <= 0.0) |
|
| 98 | + { |
|
| 99 | + // use the default timeout |
|
| 100 | + $timeout = $this->getDefaultTimeout(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // set curl GET options |
|
| 104 | + curl_setopt_array($this->_curl, array( |
|
| 105 | + // make sure we're returning the body |
|
| 106 | + CURLOPT_NOBODY => false, |
|
| 107 | + |
|
| 108 | + // make sure we're GET |
|
| 109 | + CURLOPT_HTTPGET => true, |
|
| 110 | + |
|
| 111 | + // set the URL |
|
| 112 | + CURLOPT_URL => $url, |
|
| 113 | + |
|
| 114 | + // set the timeout |
|
| 115 | + CURLOPT_TIMEOUT => $timeout |
|
| 116 | + )); |
|
| 117 | + |
|
| 118 | + // make the request |
|
| 119 | + $responseBody = curl_exec($this->_curl); |
|
| 120 | + |
|
| 121 | + // get info from the transfer |
|
| 122 | + $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); |
|
| 123 | + $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); |
|
| 124 | + |
|
| 125 | + return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + public function performHeadRequest($url, $timeout = false) |
|
| 129 | + { |
|
| 130 | + // check the timeout value |
|
| 131 | + if ($timeout === false || $timeout <= 0.0) |
|
| 132 | + { |
|
| 133 | + // use the default timeout |
|
| 134 | + $timeout = $this->getDefaultTimeout(); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // set curl HEAD options |
|
| 138 | + curl_setopt_array($this->_curl, array( |
|
| 139 | + // this both sets the method to HEAD and says not to return a body |
|
| 140 | + CURLOPT_NOBODY => true, |
|
| 141 | + |
|
| 142 | + // set the URL |
|
| 143 | + CURLOPT_URL => $url, |
|
| 144 | + |
|
| 145 | + // set the timeout |
|
| 146 | + CURLOPT_TIMEOUT => $timeout |
|
| 147 | + )); |
|
| 148 | + |
|
| 149 | + // make the request |
|
| 150 | + $responseBody = curl_exec($this->_curl); |
|
| 151 | + |
|
| 152 | + // get info from the transfer |
|
| 153 | + $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); |
|
| 154 | + $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); |
|
| 155 | + |
|
| 156 | + return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 160 | + { |
|
| 161 | + // check the timeout value |
|
| 162 | + if ($timeout === false || $timeout <= 0.0) |
|
| 163 | + { |
|
| 164 | + // use the default timeout |
|
| 165 | + $timeout = $this->getDefaultTimeout(); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + // set curl POST options |
|
| 169 | + curl_setopt_array($this->_curl, array( |
|
| 170 | + // make sure we're returning the body |
|
| 171 | + CURLOPT_NOBODY => false, |
|
| 172 | + |
|
| 173 | + // make sure we're POST |
|
| 174 | + CURLOPT_POST => true, |
|
| 175 | + |
|
| 176 | + // set the URL |
|
| 177 | + CURLOPT_URL => $url, |
|
| 178 | + |
|
| 179 | + // set the post data |
|
| 180 | + CURLOPT_POSTFIELDS => $postData, |
|
| 181 | + |
|
| 182 | + // set the content type |
|
| 183 | + CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), |
|
| 184 | + |
|
| 185 | + // set the timeout |
|
| 186 | + CURLOPT_TIMEOUT => $timeout |
|
| 187 | + )); |
|
| 188 | + |
|
| 189 | + // make the request |
|
| 190 | + $responseBody = curl_exec($this->_curl); |
|
| 191 | + |
|
| 192 | + // get info from the transfer |
|
| 193 | + $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); |
|
| 194 | + $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); |
|
| 195 | + |
|
| 196 | + return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 197 | + } |
|
| 198 | 198 | } |
| 199 | 199 | \ No newline at end of file |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | 39 | // Require Apache_Solr_HttpTransport_Abstract |
| 40 | -require_once(dirname(__FILE__) . '/Abstract.php'); |
|
| 40 | +require_once(dirname(__FILE__).'/Abstract.php'); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * A Curl based HTTP transport. Uses a single curl session for all requests. |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $this->_curl = curl_init(); |
| 71 | 71 | |
| 72 | 72 | // set common options that will not be changed during the session |
| 73 | - curl_setopt_array($this->_curl, array( |
|
| 73 | + curl_setopt_array($this->_curl, array ( |
|
| 74 | 74 | // return the response body from curl_exec |
| 75 | 75 | CURLOPT_RETURNTRANSFER => true, |
| 76 | 76 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // set curl GET options |
| 104 | - curl_setopt_array($this->_curl, array( |
|
| 104 | + curl_setopt_array($this->_curl, array ( |
|
| 105 | 105 | // make sure we're returning the body |
| 106 | 106 | CURLOPT_NOBODY => false, |
| 107 | 107 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // set curl HEAD options |
| 138 | - curl_setopt_array($this->_curl, array( |
|
| 138 | + curl_setopt_array($this->_curl, array ( |
|
| 139 | 139 | // this both sets the method to HEAD and says not to return a body |
| 140 | 140 | CURLOPT_NOBODY => true, |
| 141 | 141 | |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // set curl POST options |
| 169 | - curl_setopt_array($this->_curl, array( |
|
| 169 | + curl_setopt_array($this->_curl, array ( |
|
| 170 | 170 | // make sure we're returning the body |
| 171 | 171 | CURLOPT_NOBODY => false, |
| 172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | CURLOPT_POSTFIELDS => $postData, |
| 181 | 181 | |
| 182 | 182 | // set the content type |
| 183 | - CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), |
|
| 183 | + CURLOPT_HTTPHEADER => array ("Content-Type: {$contentType}"), |
|
| 184 | 184 | |
| 185 | 185 | // set the timeout |
| 186 | 186 | CURLOPT_TIMEOUT => $timeout |
@@ -42,8 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * A Curl based HTTP transport. Uses a single curl session for all requests. |
| 44 | 44 | */ |
| 45 | -class Apache_Solr_HttpTransport_Curl extends Apache_Solr_HttpTransport_Abstract |
|
| 46 | -{ |
|
| 45 | +class Apache_Solr_HttpTransport_Curl extends Apache_Solr_HttpTransport_Abstract { |
|
| 47 | 46 | /** |
| 48 | 47 | * SVN Revision meta data for this class |
| 49 | 48 | */ |
@@ -64,8 +63,7 @@ discard block |
||
| 64 | 63 | /** |
| 65 | 64 | * Initializes a curl session |
| 66 | 65 | */ |
| 67 | - public function __construct() |
|
| 68 | - { |
|
| 66 | + public function __construct() { |
|
| 69 | 67 | // initialize a CURL session |
| 70 | 68 | $this->_curl = curl_init(); |
| 71 | 69 | |
@@ -85,17 +83,14 @@ discard block |
||
| 85 | 83 | /** |
| 86 | 84 | * Closes a curl session |
| 87 | 85 | */ |
| 88 | - function __destruct() |
|
| 89 | - { |
|
| 86 | + function __destruct() { |
|
| 90 | 87 | // close our curl session |
| 91 | 88 | curl_close($this->_curl); |
| 92 | 89 | } |
| 93 | 90 | |
| 94 | - public function performGetRequest($url, $timeout = false) |
|
| 95 | - { |
|
| 91 | + public function performGetRequest($url, $timeout = false) { |
|
| 96 | 92 | // check the timeout value |
| 97 | - if ($timeout === false || $timeout <= 0.0) |
|
| 98 | - { |
|
| 93 | + if ($timeout === false || $timeout <= 0.0) { |
|
| 99 | 94 | // use the default timeout |
| 100 | 95 | $timeout = $this->getDefaultTimeout(); |
| 101 | 96 | } |
@@ -125,11 +120,9 @@ discard block |
||
| 125 | 120 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 126 | 121 | } |
| 127 | 122 | |
| 128 | - public function performHeadRequest($url, $timeout = false) |
|
| 129 | - { |
|
| 123 | + public function performHeadRequest($url, $timeout = false) { |
|
| 130 | 124 | // check the timeout value |
| 131 | - if ($timeout === false || $timeout <= 0.0) |
|
| 132 | - { |
|
| 125 | + if ($timeout === false || $timeout <= 0.0) { |
|
| 133 | 126 | // use the default timeout |
| 134 | 127 | $timeout = $this->getDefaultTimeout(); |
| 135 | 128 | } |
@@ -156,11 +149,9 @@ discard block |
||
| 156 | 149 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 157 | 150 | } |
| 158 | 151 | |
| 159 | - public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 160 | - { |
|
| 152 | + public function performPostRequest($url, $postData, $contentType, $timeout = false) { |
|
| 161 | 153 | // check the timeout value |
| 162 | - if ($timeout === false || $timeout <= 0.0) |
|
| 163 | - { |
|
| 154 | + if ($timeout === false || $timeout <= 0.0) { |
|
| 164 | 155 | // use the default timeout |
| 165 | 156 | $timeout = $this->getDefaultTimeout(); |
| 166 | 157 | } |
@@ -72,13 +72,13 @@ discard block |
||
| 72 | 72 | // set common options that will not be changed during the session |
| 73 | 73 | curl_setopt_array($this->_curl, array( |
| 74 | 74 | // return the response body from curl_exec |
| 75 | - CURLOPT_RETURNTRANSFER => true, |
|
| 75 | + CURLOPT_RETURNTRANSFER => TRUE, |
|
| 76 | 76 | |
| 77 | 77 | // get the output as binary data |
| 78 | - CURLOPT_BINARYTRANSFER => true, |
|
| 78 | + CURLOPT_BINARYTRANSFER => TRUE, |
|
| 79 | 79 | |
| 80 | 80 | // we do not need the headers in the output, we get everything we need from curl_getinfo |
| 81 | - CURLOPT_HEADER => false |
|
| 81 | + CURLOPT_HEADER => FALSE |
|
| 82 | 82 | )); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -91,10 +91,10 @@ discard block |
||
| 91 | 91 | curl_close($this->_curl); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - public function performGetRequest($url, $timeout = false) |
|
| 94 | + public function performGetRequest($url, $timeout = FALSE) |
|
| 95 | 95 | { |
| 96 | 96 | // check the timeout value |
| 97 | - if ($timeout === false || $timeout <= 0.0) |
|
| 97 | + if ($timeout === FALSE || $timeout <= 0.0) |
|
| 98 | 98 | { |
| 99 | 99 | // use the default timeout |
| 100 | 100 | $timeout = $this->getDefaultTimeout(); |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | // set curl GET options |
| 104 | 104 | curl_setopt_array($this->_curl, array( |
| 105 | 105 | // make sure we're returning the body |
| 106 | - CURLOPT_NOBODY => false, |
|
| 106 | + CURLOPT_NOBODY => FALSE, |
|
| 107 | 107 | |
| 108 | 108 | // make sure we're GET |
| 109 | - CURLOPT_HTTPGET => true, |
|
| 109 | + CURLOPT_HTTPGET => TRUE, |
|
| 110 | 110 | |
| 111 | 111 | // set the URL |
| 112 | 112 | CURLOPT_URL => $url, |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function performHeadRequest($url, $timeout = false) |
|
| 128 | + public function performHeadRequest($url, $timeout = FALSE) |
|
| 129 | 129 | { |
| 130 | 130 | // check the timeout value |
| 131 | - if ($timeout === false || $timeout <= 0.0) |
|
| 131 | + if ($timeout === FALSE || $timeout <= 0.0) |
|
| 132 | 132 | { |
| 133 | 133 | // use the default timeout |
| 134 | 134 | $timeout = $this->getDefaultTimeout(); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | // set curl HEAD options |
| 138 | 138 | curl_setopt_array($this->_curl, array( |
| 139 | 139 | // this both sets the method to HEAD and says not to return a body |
| 140 | - CURLOPT_NOBODY => true, |
|
| 140 | + CURLOPT_NOBODY => TRUE, |
|
| 141 | 141 | |
| 142 | 142 | // set the URL |
| 143 | 143 | CURLOPT_URL => $url, |
@@ -156,10 +156,10 @@ discard block |
||
| 156 | 156 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 159 | + public function performPostRequest($url, $postData, $contentType, $timeout = FALSE) |
|
| 160 | 160 | { |
| 161 | 161 | // check the timeout value |
| 162 | - if ($timeout === false || $timeout <= 0.0) |
|
| 162 | + if ($timeout === FALSE || $timeout <= 0.0) |
|
| 163 | 163 | { |
| 164 | 164 | // use the default timeout |
| 165 | 165 | $timeout = $this->getDefaultTimeout(); |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | // set curl POST options |
| 169 | 169 | curl_setopt_array($this->_curl, array( |
| 170 | 170 | // make sure we're returning the body |
| 171 | - CURLOPT_NOBODY => false, |
|
| 171 | + CURLOPT_NOBODY => FALSE, |
|
| 172 | 172 | |
| 173 | 173 | // make sure we're POST |
| 174 | - CURLOPT_POST => true, |
|
| 174 | + CURLOPT_POST => TRUE, |
|
| 175 | 175 | |
| 176 | 176 | // set the URL |
| 177 | 177 | CURLOPT_URL => $url, |
@@ -43,213 +43,213 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class Apache_Solr_HttpTransport_Response |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * Status Messages indexed by Status Code |
|
| 48 | - * Obtained from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html |
|
| 49 | - * |
|
| 50 | - * @var array |
|
| 51 | - */ |
|
| 52 | - static private $_defaultStatusMessages = array( |
|
| 53 | - // Specific to PHP Solr Client |
|
| 54 | - 0 => "Communication Error", |
|
| 46 | + /** |
|
| 47 | + * Status Messages indexed by Status Code |
|
| 48 | + * Obtained from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html |
|
| 49 | + * |
|
| 50 | + * @var array |
|
| 51 | + */ |
|
| 52 | + static private $_defaultStatusMessages = array( |
|
| 53 | + // Specific to PHP Solr Client |
|
| 54 | + 0 => "Communication Error", |
|
| 55 | 55 | |
| 56 | - // Informational 1XX |
|
| 57 | - 100 => "Continue", |
|
| 58 | - 101 => "Switching Protocols", |
|
| 56 | + // Informational 1XX |
|
| 57 | + 100 => "Continue", |
|
| 58 | + 101 => "Switching Protocols", |
|
| 59 | 59 | |
| 60 | - // Successful 2XX |
|
| 61 | - 200 => "OK", |
|
| 62 | - 201 => "Created", |
|
| 63 | - 202 => "Accepted", |
|
| 64 | - 203 => "Non-Authoritative Information", |
|
| 65 | - 204 => "No Content", |
|
| 66 | - 205 => "Reset Content", |
|
| 67 | - 206 => "Partial Content", |
|
| 60 | + // Successful 2XX |
|
| 61 | + 200 => "OK", |
|
| 62 | + 201 => "Created", |
|
| 63 | + 202 => "Accepted", |
|
| 64 | + 203 => "Non-Authoritative Information", |
|
| 65 | + 204 => "No Content", |
|
| 66 | + 205 => "Reset Content", |
|
| 67 | + 206 => "Partial Content", |
|
| 68 | 68 | |
| 69 | - // Redirection 3XX |
|
| 70 | - 300 => "Multiple Choices", |
|
| 71 | - 301 => "Moved Permanently", |
|
| 72 | - 302 => "Found", |
|
| 73 | - 303 => "See Other", |
|
| 74 | - 304 => "Not Modified", |
|
| 75 | - 305 => "Use Proxy", |
|
| 76 | - 307 => "Temporary Redirect", |
|
| 69 | + // Redirection 3XX |
|
| 70 | + 300 => "Multiple Choices", |
|
| 71 | + 301 => "Moved Permanently", |
|
| 72 | + 302 => "Found", |
|
| 73 | + 303 => "See Other", |
|
| 74 | + 304 => "Not Modified", |
|
| 75 | + 305 => "Use Proxy", |
|
| 76 | + 307 => "Temporary Redirect", |
|
| 77 | 77 | |
| 78 | - // Client Error 4XX |
|
| 79 | - 400 => "Bad Request", |
|
| 80 | - 401 => "Unauthorized", |
|
| 81 | - 402 => "Payment Required", |
|
| 82 | - 403 => "Forbidden", |
|
| 83 | - 404 => "Not Found", |
|
| 84 | - 405 => "Method Not Allowed", |
|
| 85 | - 406 => "Not Acceptable", |
|
| 86 | - 407 => "Proxy Authentication Required", |
|
| 87 | - 408 => "Request Timeout", |
|
| 88 | - 409 => "Conflict", |
|
| 89 | - 410 => "Gone", |
|
| 90 | - 411 => "Length Required", |
|
| 91 | - 412 => "Precondition Failed", |
|
| 92 | - 413 => "Request Entity Too Large", |
|
| 93 | - 414 => "Request-URI Too Long", |
|
| 94 | - 415 => "Unsupported Media Type", |
|
| 95 | - 416 => "Request Range Not Satisfiable", |
|
| 96 | - 417 => "Expectation Failed", |
|
| 78 | + // Client Error 4XX |
|
| 79 | + 400 => "Bad Request", |
|
| 80 | + 401 => "Unauthorized", |
|
| 81 | + 402 => "Payment Required", |
|
| 82 | + 403 => "Forbidden", |
|
| 83 | + 404 => "Not Found", |
|
| 84 | + 405 => "Method Not Allowed", |
|
| 85 | + 406 => "Not Acceptable", |
|
| 86 | + 407 => "Proxy Authentication Required", |
|
| 87 | + 408 => "Request Timeout", |
|
| 88 | + 409 => "Conflict", |
|
| 89 | + 410 => "Gone", |
|
| 90 | + 411 => "Length Required", |
|
| 91 | + 412 => "Precondition Failed", |
|
| 92 | + 413 => "Request Entity Too Large", |
|
| 93 | + 414 => "Request-URI Too Long", |
|
| 94 | + 415 => "Unsupported Media Type", |
|
| 95 | + 416 => "Request Range Not Satisfiable", |
|
| 96 | + 417 => "Expectation Failed", |
|
| 97 | 97 | |
| 98 | - // Server Error 5XX |
|
| 99 | - 500 => "Internal Server Error", |
|
| 100 | - 501 => "Not Implemented", |
|
| 101 | - 502 => "Bad Gateway", |
|
| 102 | - 503 => "Service Unavailable", |
|
| 103 | - 504 => "Gateway Timeout", |
|
| 104 | - 505 => "HTTP Version Not Supported" |
|
| 105 | - ); |
|
| 98 | + // Server Error 5XX |
|
| 99 | + 500 => "Internal Server Error", |
|
| 100 | + 501 => "Not Implemented", |
|
| 101 | + 502 => "Bad Gateway", |
|
| 102 | + 503 => "Service Unavailable", |
|
| 103 | + 504 => "Gateway Timeout", |
|
| 104 | + 505 => "HTTP Version Not Supported" |
|
| 105 | + ); |
|
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * Get the HTTP status message based on status code |
|
| 109 | - * |
|
| 110 | - * @return string |
|
| 111 | - */ |
|
| 112 | - public static function getDefaultStatusMessage($statusCode) |
|
| 113 | - { |
|
| 114 | - $statusCode = (int) $statusCode; |
|
| 107 | + /** |
|
| 108 | + * Get the HTTP status message based on status code |
|
| 109 | + * |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 112 | + public static function getDefaultStatusMessage($statusCode) |
|
| 113 | + { |
|
| 114 | + $statusCode = (int) $statusCode; |
|
| 115 | 115 | |
| 116 | - if (isset(self::$_defaultStatusMessages[$statusCode])) |
|
| 117 | - { |
|
| 118 | - return self::$_defaultStatusMessages[$statusCode]; |
|
| 119 | - } |
|
| 116 | + if (isset(self::$_defaultStatusMessages[$statusCode])) |
|
| 117 | + { |
|
| 118 | + return self::$_defaultStatusMessages[$statusCode]; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - return "Unknown Status"; |
|
| 122 | - } |
|
| 121 | + return "Unknown Status"; |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * The response's HTTP status code |
|
| 126 | - * |
|
| 127 | - * @var integer |
|
| 128 | - */ |
|
| 129 | - private $_statusCode; |
|
| 124 | + /** |
|
| 125 | + * The response's HTTP status code |
|
| 126 | + * |
|
| 127 | + * @var integer |
|
| 128 | + */ |
|
| 129 | + private $_statusCode; |
|
| 130 | 130 | |
| 131 | - /** |
|
| 132 | - * The response's HTTP status message |
|
| 133 | - * |
|
| 134 | - * @var string |
|
| 135 | - */ |
|
| 136 | - private $_statusMessage; |
|
| 131 | + /** |
|
| 132 | + * The response's HTTP status message |
|
| 133 | + * |
|
| 134 | + * @var string |
|
| 135 | + */ |
|
| 136 | + private $_statusMessage; |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * The response's mime type |
|
| 140 | - * |
|
| 141 | - * @var string |
|
| 142 | - */ |
|
| 143 | - private $_mimeType; |
|
| 138 | + /** |
|
| 139 | + * The response's mime type |
|
| 140 | + * |
|
| 141 | + * @var string |
|
| 142 | + */ |
|
| 143 | + private $_mimeType; |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * The response's character encoding |
|
| 147 | - * |
|
| 148 | - * @var string |
|
| 149 | - */ |
|
| 150 | - private $_encoding; |
|
| 145 | + /** |
|
| 146 | + * The response's character encoding |
|
| 147 | + * |
|
| 148 | + * @var string |
|
| 149 | + */ |
|
| 150 | + private $_encoding; |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * The response's data |
|
| 154 | - * |
|
| 155 | - * @var string |
|
| 156 | - */ |
|
| 157 | - private $_responseBody; |
|
| 152 | + /** |
|
| 153 | + * The response's data |
|
| 154 | + * |
|
| 155 | + * @var string |
|
| 156 | + */ |
|
| 157 | + private $_responseBody; |
|
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Construct a HTTP transport response |
|
| 161 | - * |
|
| 162 | - * @param integer $statusCode The HTTP status code |
|
| 163 | - * @param string $contentType The VALUE of the Content-Type HTTP header |
|
| 164 | - * @param string $responseBody The body of the HTTP response |
|
| 165 | - */ |
|
| 166 | - public function __construct($statusCode, $contentType, $responseBody) |
|
| 167 | - { |
|
| 168 | - // set the status code, make sure its an integer |
|
| 169 | - $this->_statusCode = (int) $statusCode; |
|
| 159 | + /** |
|
| 160 | + * Construct a HTTP transport response |
|
| 161 | + * |
|
| 162 | + * @param integer $statusCode The HTTP status code |
|
| 163 | + * @param string $contentType The VALUE of the Content-Type HTTP header |
|
| 164 | + * @param string $responseBody The body of the HTTP response |
|
| 165 | + */ |
|
| 166 | + public function __construct($statusCode, $contentType, $responseBody) |
|
| 167 | + { |
|
| 168 | + // set the status code, make sure its an integer |
|
| 169 | + $this->_statusCode = (int) $statusCode; |
|
| 170 | 170 | |
| 171 | - // lookup up status message based on code |
|
| 172 | - $this->_statusMessage = self::getDefaultStatusMessage($this->_statusCode); |
|
| 171 | + // lookup up status message based on code |
|
| 172 | + $this->_statusMessage = self::getDefaultStatusMessage($this->_statusCode); |
|
| 173 | 173 | |
| 174 | - // set the response body, it should always be a string |
|
| 175 | - $this->_responseBody = (string) $responseBody; |
|
| 174 | + // set the response body, it should always be a string |
|
| 175 | + $this->_responseBody = (string) $responseBody; |
|
| 176 | 176 | |
| 177 | - // parse the content type header value for mimetype and encoding |
|
| 178 | - // first set default values that will remain if we can't find |
|
| 179 | - // what we're looking for in the content type |
|
| 180 | - $this->_mimeType = "text/plain"; |
|
| 181 | - $this->_encoding = "UTF-8"; |
|
| 177 | + // parse the content type header value for mimetype and encoding |
|
| 178 | + // first set default values that will remain if we can't find |
|
| 179 | + // what we're looking for in the content type |
|
| 180 | + $this->_mimeType = "text/plain"; |
|
| 181 | + $this->_encoding = "UTF-8"; |
|
| 182 | 182 | |
| 183 | - if ($contentType) |
|
| 184 | - { |
|
| 185 | - // now break apart the header to see if there's character encoding |
|
| 186 | - $contentTypeParts = explode(';', $contentType, 2); |
|
| 183 | + if ($contentType) |
|
| 184 | + { |
|
| 185 | + // now break apart the header to see if there's character encoding |
|
| 186 | + $contentTypeParts = explode(';', $contentType, 2); |
|
| 187 | 187 | |
| 188 | - if (isset($contentTypeParts[0])) |
|
| 189 | - { |
|
| 190 | - $this->_mimeType = trim($contentTypeParts[0]); |
|
| 191 | - } |
|
| 188 | + if (isset($contentTypeParts[0])) |
|
| 189 | + { |
|
| 190 | + $this->_mimeType = trim($contentTypeParts[0]); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - if (isset($contentTypeParts[1])) |
|
| 194 | - { |
|
| 195 | - // we have a second part, split it further |
|
| 196 | - $contentTypeParts = explode('=', $contentTypeParts[1]); |
|
| 193 | + if (isset($contentTypeParts[1])) |
|
| 194 | + { |
|
| 195 | + // we have a second part, split it further |
|
| 196 | + $contentTypeParts = explode('=', $contentTypeParts[1]); |
|
| 197 | 197 | |
| 198 | - if (isset($contentTypeParts[1])) |
|
| 199 | - { |
|
| 200 | - $this->_encoding = trim($contentTypeParts[1]); |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - } |
|
| 198 | + if (isset($contentTypeParts[1])) |
|
| 199 | + { |
|
| 200 | + $this->_encoding = trim($contentTypeParts[1]); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * Get the status code of the response |
|
| 208 | - * |
|
| 209 | - * @return integer |
|
| 210 | - */ |
|
| 211 | - public function getStatusCode() |
|
| 212 | - { |
|
| 213 | - return $this->_statusCode; |
|
| 214 | - } |
|
| 206 | + /** |
|
| 207 | + * Get the status code of the response |
|
| 208 | + * |
|
| 209 | + * @return integer |
|
| 210 | + */ |
|
| 211 | + public function getStatusCode() |
|
| 212 | + { |
|
| 213 | + return $this->_statusCode; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - /** |
|
| 217 | - * Get the status message of the response |
|
| 218 | - * |
|
| 219 | - * @return string |
|
| 220 | - */ |
|
| 221 | - public function getStatusMessage() |
|
| 222 | - { |
|
| 223 | - return $this->_statusMessage; |
|
| 224 | - } |
|
| 216 | + /** |
|
| 217 | + * Get the status message of the response |
|
| 218 | + * |
|
| 219 | + * @return string |
|
| 220 | + */ |
|
| 221 | + public function getStatusMessage() |
|
| 222 | + { |
|
| 223 | + return $this->_statusMessage; |
|
| 224 | + } |
|
| 225 | 225 | |
| 226 | - /** |
|
| 227 | - * Get the mimetype of the response body |
|
| 228 | - * |
|
| 229 | - * @return string |
|
| 230 | - */ |
|
| 231 | - public function getMimeType() |
|
| 232 | - { |
|
| 233 | - return $this->_mimeType; |
|
| 234 | - } |
|
| 226 | + /** |
|
| 227 | + * Get the mimetype of the response body |
|
| 228 | + * |
|
| 229 | + * @return string |
|
| 230 | + */ |
|
| 231 | + public function getMimeType() |
|
| 232 | + { |
|
| 233 | + return $this->_mimeType; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Get the charset encoding of the response body. |
|
| 238 | - * |
|
| 239 | - * @return string |
|
| 240 | - */ |
|
| 241 | - public function getEncoding() |
|
| 242 | - { |
|
| 243 | - return $this->_encoding; |
|
| 244 | - } |
|
| 236 | + /** |
|
| 237 | + * Get the charset encoding of the response body. |
|
| 238 | + * |
|
| 239 | + * @return string |
|
| 240 | + */ |
|
| 241 | + public function getEncoding() |
|
| 242 | + { |
|
| 243 | + return $this->_encoding; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - /** |
|
| 247 | - * Get the raw response body |
|
| 248 | - * |
|
| 249 | - * @return string |
|
| 250 | - */ |
|
| 251 | - public function getBody() |
|
| 252 | - { |
|
| 253 | - return $this->_responseBody; |
|
| 254 | - } |
|
| 246 | + /** |
|
| 247 | + * Get the raw response body |
|
| 248 | + * |
|
| 249 | + * @return string |
|
| 250 | + */ |
|
| 251 | + public function getBody() |
|
| 252 | + { |
|
| 253 | + return $this->_responseBody; |
|
| 254 | + } |
|
| 255 | 255 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | * |
| 50 | 50 | * @var array |
| 51 | 51 | */ |
| 52 | - static private $_defaultStatusMessages = array( |
|
| 52 | + static private $_defaultStatusMessages = array ( |
|
| 53 | 53 | // Specific to PHP Solr Client |
| 54 | 54 | 0 => "Communication Error", |
| 55 | 55 | |
@@ -41,8 +41,7 @@ discard block |
||
| 41 | 41 | * implementations and then consumed by the Apache_Solr_Response class which provides |
| 42 | 42 | * decoding |
| 43 | 43 | */ |
| 44 | -class Apache_Solr_HttpTransport_Response |
|
| 45 | -{ |
|
| 44 | +class Apache_Solr_HttpTransport_Response { |
|
| 46 | 45 | /** |
| 47 | 46 | * Status Messages indexed by Status Code |
| 48 | 47 | * Obtained from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html |
@@ -109,12 +108,10 @@ discard block |
||
| 109 | 108 | * |
| 110 | 109 | * @return string |
| 111 | 110 | */ |
| 112 | - public static function getDefaultStatusMessage($statusCode) |
|
| 113 | - { |
|
| 111 | + public static function getDefaultStatusMessage($statusCode) { |
|
| 114 | 112 | $statusCode = (int) $statusCode; |
| 115 | 113 | |
| 116 | - if (isset(self::$_defaultStatusMessages[$statusCode])) |
|
| 117 | - { |
|
| 114 | + if (isset(self::$_defaultStatusMessages[$statusCode])) { |
|
| 118 | 115 | return self::$_defaultStatusMessages[$statusCode]; |
| 119 | 116 | } |
| 120 | 117 | |
@@ -163,8 +160,7 @@ discard block |
||
| 163 | 160 | * @param string $contentType The VALUE of the Content-Type HTTP header |
| 164 | 161 | * @param string $responseBody The body of the HTTP response |
| 165 | 162 | */ |
| 166 | - public function __construct($statusCode, $contentType, $responseBody) |
|
| 167 | - { |
|
| 163 | + public function __construct($statusCode, $contentType, $responseBody) { |
|
| 168 | 164 | // set the status code, make sure its an integer |
| 169 | 165 | $this->_statusCode = (int) $statusCode; |
| 170 | 166 | |
@@ -180,23 +176,19 @@ discard block |
||
| 180 | 176 | $this->_mimeType = "text/plain"; |
| 181 | 177 | $this->_encoding = "UTF-8"; |
| 182 | 178 | |
| 183 | - if ($contentType) |
|
| 184 | - { |
|
| 179 | + if ($contentType) { |
|
| 185 | 180 | // now break apart the header to see if there's character encoding |
| 186 | 181 | $contentTypeParts = explode(';', $contentType, 2); |
| 187 | 182 | |
| 188 | - if (isset($contentTypeParts[0])) |
|
| 189 | - { |
|
| 183 | + if (isset($contentTypeParts[0])) { |
|
| 190 | 184 | $this->_mimeType = trim($contentTypeParts[0]); |
| 191 | 185 | } |
| 192 | 186 | |
| 193 | - if (isset($contentTypeParts[1])) |
|
| 194 | - { |
|
| 187 | + if (isset($contentTypeParts[1])) { |
|
| 195 | 188 | // we have a second part, split it further |
| 196 | 189 | $contentTypeParts = explode('=', $contentTypeParts[1]); |
| 197 | 190 | |
| 198 | - if (isset($contentTypeParts[1])) |
|
| 199 | - { |
|
| 191 | + if (isset($contentTypeParts[1])) { |
|
| 200 | 192 | $this->_encoding = trim($contentTypeParts[1]); |
| 201 | 193 | } |
| 202 | 194 | } |
@@ -208,8 +200,7 @@ discard block |
||
| 208 | 200 | * |
| 209 | 201 | * @return integer |
| 210 | 202 | */ |
| 211 | - public function getStatusCode() |
|
| 212 | - { |
|
| 203 | + public function getStatusCode() { |
|
| 213 | 204 | return $this->_statusCode; |
| 214 | 205 | } |
| 215 | 206 | |
@@ -218,8 +209,7 @@ discard block |
||
| 218 | 209 | * |
| 219 | 210 | * @return string |
| 220 | 211 | */ |
| 221 | - public function getStatusMessage() |
|
| 222 | - { |
|
| 212 | + public function getStatusMessage() { |
|
| 223 | 213 | return $this->_statusMessage; |
| 224 | 214 | } |
| 225 | 215 | |
@@ -228,8 +218,7 @@ discard block |
||
| 228 | 218 | * |
| 229 | 219 | * @return string |
| 230 | 220 | */ |
| 231 | - public function getMimeType() |
|
| 232 | - { |
|
| 221 | + public function getMimeType() { |
|
| 233 | 222 | return $this->_mimeType; |
| 234 | 223 | } |
| 235 | 224 | |
@@ -238,8 +227,7 @@ discard block |
||
| 238 | 227 | * |
| 239 | 228 | * @return string |
| 240 | 229 | */ |
| 241 | - public function getEncoding() |
|
| 242 | - { |
|
| 230 | + public function getEncoding() { |
|
| 243 | 231 | return $this->_encoding; |
| 244 | 232 | } |
| 245 | 233 | |
@@ -248,8 +236,7 @@ discard block |
||
| 248 | 236 | * |
| 249 | 237 | * @return string |
| 250 | 238 | */ |
| 251 | - public function getBody() |
|
| 252 | - { |
|
| 239 | + public function getBody() { |
|
| 253 | 240 | return $this->_responseBody; |
| 254 | 241 | } |
| 255 | 242 | } |
@@ -46,151 +46,151 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | class Apache_Solr_HttpTransport_CurlNoReuse extends Apache_Solr_HttpTransport_Abstract |
| 48 | 48 | { |
| 49 | - /** |
|
| 50 | - * SVN Revision meta data for this class |
|
| 51 | - */ |
|
| 52 | - const SVN_REVISION = '$Revision:$'; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * SVN ID meta data for this class |
|
| 56 | - */ |
|
| 57 | - const SVN_ID = '$Id:$'; |
|
| 58 | - |
|
| 59 | - public function performGetRequest($url, $timeout = false) |
|
| 60 | - { |
|
| 61 | - // check the timeout value |
|
| 62 | - if ($timeout === false || $timeout <= 0.0) |
|
| 63 | - { |
|
| 64 | - // use the default timeout |
|
| 65 | - $timeout = $this->getDefaultTimeout(); |
|
| 66 | - } |
|
| 49 | + /** |
|
| 50 | + * SVN Revision meta data for this class |
|
| 51 | + */ |
|
| 52 | + const SVN_REVISION = '$Revision:$'; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * SVN ID meta data for this class |
|
| 56 | + */ |
|
| 57 | + const SVN_ID = '$Id:$'; |
|
| 58 | + |
|
| 59 | + public function performGetRequest($url, $timeout = false) |
|
| 60 | + { |
|
| 61 | + // check the timeout value |
|
| 62 | + if ($timeout === false || $timeout <= 0.0) |
|
| 63 | + { |
|
| 64 | + // use the default timeout |
|
| 65 | + $timeout = $this->getDefaultTimeout(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $curl = curl_init(); |
|
| 68 | + $curl = curl_init(); |
|
| 69 | 69 | |
| 70 | - // set curl GET options |
|
| 71 | - curl_setopt_array($curl, array( |
|
| 72 | - // return the response body from curl_exec |
|
| 73 | - CURLOPT_RETURNTRANSFER => true, |
|
| 70 | + // set curl GET options |
|
| 71 | + curl_setopt_array($curl, array( |
|
| 72 | + // return the response body from curl_exec |
|
| 73 | + CURLOPT_RETURNTRANSFER => true, |
|
| 74 | 74 | |
| 75 | - // get the output as binary data |
|
| 76 | - CURLOPT_BINARYTRANSFER => true, |
|
| 75 | + // get the output as binary data |
|
| 76 | + CURLOPT_BINARYTRANSFER => true, |
|
| 77 | 77 | |
| 78 | - // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 79 | - CURLOPT_HEADER => false, |
|
| 78 | + // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 79 | + CURLOPT_HEADER => false, |
|
| 80 | 80 | |
| 81 | - // set the URL |
|
| 82 | - CURLOPT_URL => $url, |
|
| 81 | + // set the URL |
|
| 82 | + CURLOPT_URL => $url, |
|
| 83 | 83 | |
| 84 | - // set the timeout |
|
| 85 | - CURLOPT_TIMEOUT => $timeout |
|
| 86 | - )); |
|
| 84 | + // set the timeout |
|
| 85 | + CURLOPT_TIMEOUT => $timeout |
|
| 86 | + )); |
|
| 87 | 87 | |
| 88 | - // make the request |
|
| 89 | - $responseBody = curl_exec($curl); |
|
| 88 | + // make the request |
|
| 89 | + $responseBody = curl_exec($curl); |
|
| 90 | 90 | |
| 91 | - // get info from the transfer |
|
| 92 | - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 93 | - $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); |
|
| 91 | + // get info from the transfer |
|
| 92 | + $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 93 | + $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); |
|
| 94 | 94 | |
| 95 | - // close our curl session - we're done with it |
|
| 96 | - curl_close($curl); |
|
| 97 | - |
|
| 98 | - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - public function performHeadRequest($url, $timeout = false) |
|
| 102 | - { |
|
| 103 | - // check the timeout value |
|
| 104 | - if ($timeout === false || $timeout <= 0.0) |
|
| 105 | - { |
|
| 106 | - // use the default timeout |
|
| 107 | - $timeout = $this->getDefaultTimeout(); |
|
| 108 | - } |
|
| 95 | + // close our curl session - we're done with it |
|
| 96 | + curl_close($curl); |
|
| 97 | + |
|
| 98 | + return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + public function performHeadRequest($url, $timeout = false) |
|
| 102 | + { |
|
| 103 | + // check the timeout value |
|
| 104 | + if ($timeout === false || $timeout <= 0.0) |
|
| 105 | + { |
|
| 106 | + // use the default timeout |
|
| 107 | + $timeout = $this->getDefaultTimeout(); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - $curl = curl_init(); |
|
| 110 | + $curl = curl_init(); |
|
| 111 | 111 | |
| 112 | - // set curl HEAD options |
|
| 113 | - curl_setopt_array($curl, array( |
|
| 114 | - // return the response body from curl_exec |
|
| 115 | - CURLOPT_RETURNTRANSFER => true, |
|
| 112 | + // set curl HEAD options |
|
| 113 | + curl_setopt_array($curl, array( |
|
| 114 | + // return the response body from curl_exec |
|
| 115 | + CURLOPT_RETURNTRANSFER => true, |
|
| 116 | 116 | |
| 117 | - // get the output as binary data |
|
| 118 | - CURLOPT_BINARYTRANSFER => true, |
|
| 117 | + // get the output as binary data |
|
| 118 | + CURLOPT_BINARYTRANSFER => true, |
|
| 119 | 119 | |
| 120 | - // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 121 | - CURLOPT_HEADER => false, |
|
| 120 | + // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 121 | + CURLOPT_HEADER => false, |
|
| 122 | 122 | |
| 123 | - // this both sets the method to HEAD and says not to return a body |
|
| 124 | - CURLOPT_NOBODY => true, |
|
| 123 | + // this both sets the method to HEAD and says not to return a body |
|
| 124 | + CURLOPT_NOBODY => true, |
|
| 125 | 125 | |
| 126 | - // set the URL |
|
| 127 | - CURLOPT_URL => $url, |
|
| 126 | + // set the URL |
|
| 127 | + CURLOPT_URL => $url, |
|
| 128 | 128 | |
| 129 | - // set the timeout |
|
| 130 | - CURLOPT_TIMEOUT => $timeout |
|
| 131 | - )); |
|
| 129 | + // set the timeout |
|
| 130 | + CURLOPT_TIMEOUT => $timeout |
|
| 131 | + )); |
|
| 132 | 132 | |
| 133 | - // make the request |
|
| 134 | - $responseBody = curl_exec($curl); |
|
| 133 | + // make the request |
|
| 134 | + $responseBody = curl_exec($curl); |
|
| 135 | 135 | |
| 136 | - // get info from the transfer |
|
| 137 | - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 138 | - $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); |
|
| 136 | + // get info from the transfer |
|
| 137 | + $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 138 | + $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); |
|
| 139 | 139 | |
| 140 | - // close our curl session - we're done with it |
|
| 141 | - curl_close($curl); |
|
| 142 | - |
|
| 143 | - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 147 | - { |
|
| 148 | - // check the timeout value |
|
| 149 | - if ($timeout === false || $timeout <= 0.0) |
|
| 150 | - { |
|
| 151 | - // use the default timeout |
|
| 152 | - $timeout = $this->getDefaultTimeout(); |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - $curl = curl_init(); |
|
| 140 | + // close our curl session - we're done with it |
|
| 141 | + curl_close($curl); |
|
| 142 | + |
|
| 143 | + return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 147 | + { |
|
| 148 | + // check the timeout value |
|
| 149 | + if ($timeout === false || $timeout <= 0.0) |
|
| 150 | + { |
|
| 151 | + // use the default timeout |
|
| 152 | + $timeout = $this->getDefaultTimeout(); |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + $curl = curl_init(); |
|
| 156 | 156 | |
| 157 | - // set curl POST options |
|
| 158 | - curl_setopt_array($curl, array( |
|
| 159 | - // return the response body from curl_exec |
|
| 160 | - CURLOPT_RETURNTRANSFER => true, |
|
| 157 | + // set curl POST options |
|
| 158 | + curl_setopt_array($curl, array( |
|
| 159 | + // return the response body from curl_exec |
|
| 160 | + CURLOPT_RETURNTRANSFER => true, |
|
| 161 | 161 | |
| 162 | - // get the output as binary data |
|
| 163 | - CURLOPT_BINARYTRANSFER => true, |
|
| 162 | + // get the output as binary data |
|
| 163 | + CURLOPT_BINARYTRANSFER => true, |
|
| 164 | 164 | |
| 165 | - // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 166 | - CURLOPT_HEADER => false, |
|
| 165 | + // we do not need the headers in the output, we get everything we need from curl_getinfo |
|
| 166 | + CURLOPT_HEADER => false, |
|
| 167 | 167 | |
| 168 | - // make sure we're POST |
|
| 169 | - CURLOPT_POST => true, |
|
| 168 | + // make sure we're POST |
|
| 169 | + CURLOPT_POST => true, |
|
| 170 | 170 | |
| 171 | - // set the URL |
|
| 172 | - CURLOPT_URL => $url, |
|
| 171 | + // set the URL |
|
| 172 | + CURLOPT_URL => $url, |
|
| 173 | 173 | |
| 174 | - // set the post data |
|
| 175 | - CURLOPT_POSTFIELDS => $postData, |
|
| 174 | + // set the post data |
|
| 175 | + CURLOPT_POSTFIELDS => $postData, |
|
| 176 | 176 | |
| 177 | - // set the content type |
|
| 178 | - CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), |
|
| 177 | + // set the content type |
|
| 178 | + CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), |
|
| 179 | 179 | |
| 180 | - // set the timeout |
|
| 181 | - CURLOPT_TIMEOUT => $timeout |
|
| 182 | - )); |
|
| 180 | + // set the timeout |
|
| 181 | + CURLOPT_TIMEOUT => $timeout |
|
| 182 | + )); |
|
| 183 | 183 | |
| 184 | - // make the request |
|
| 185 | - $responseBody = curl_exec($curl); |
|
| 184 | + // make the request |
|
| 185 | + $responseBody = curl_exec($curl); |
|
| 186 | 186 | |
| 187 | - // get info from the transfer |
|
| 188 | - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 189 | - $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); |
|
| 187 | + // get info from the transfer |
|
| 188 | + $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); |
|
| 189 | + $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); |
|
| 190 | 190 | |
| 191 | - // close our curl session - we're done with it |
|
| 192 | - curl_close($curl); |
|
| 191 | + // close our curl session - we're done with it |
|
| 192 | + curl_close($curl); |
|
| 193 | 193 | |
| 194 | - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 195 | - } |
|
| 194 | + return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
|
| 195 | + } |
|
| 196 | 196 | } |
| 197 | 197 | \ No newline at end of file |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | 39 | // Require Apache_Solr_HttpTransport_Abstract |
| 40 | -require_once(dirname(__FILE__) . '/Abstract.php'); |
|
| 40 | +require_once(dirname(__FILE__).'/Abstract.php'); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * An alternative Curl HTTP transport that opens and closes a curl session for |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $curl = curl_init(); |
| 69 | 69 | |
| 70 | 70 | // set curl GET options |
| 71 | - curl_setopt_array($curl, array( |
|
| 71 | + curl_setopt_array($curl, array ( |
|
| 72 | 72 | // return the response body from curl_exec |
| 73 | 73 | CURLOPT_RETURNTRANSFER => true, |
| 74 | 74 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $curl = curl_init(); |
| 111 | 111 | |
| 112 | 112 | // set curl HEAD options |
| 113 | - curl_setopt_array($curl, array( |
|
| 113 | + curl_setopt_array($curl, array ( |
|
| 114 | 114 | // return the response body from curl_exec |
| 115 | 115 | CURLOPT_RETURNTRANSFER => true, |
| 116 | 116 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | $curl = curl_init(); |
| 156 | 156 | |
| 157 | 157 | // set curl POST options |
| 158 | - curl_setopt_array($curl, array( |
|
| 158 | + curl_setopt_array($curl, array ( |
|
| 159 | 159 | // return the response body from curl_exec |
| 160 | 160 | CURLOPT_RETURNTRANSFER => true, |
| 161 | 161 | |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | CURLOPT_POSTFIELDS => $postData, |
| 176 | 176 | |
| 177 | 177 | // set the content type |
| 178 | - CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), |
|
| 178 | + CURLOPT_HTTPHEADER => array ("Content-Type: {$contentType}"), |
|
| 179 | 179 | |
| 180 | 180 | // set the timeout |
| 181 | 181 | CURLOPT_TIMEOUT => $timeout |
@@ -44,8 +44,7 @@ discard block |
||
| 44 | 44 | * every request. This isn't the recommended way to use curl, but some version of |
| 45 | 45 | * PHP have memory issues. |
| 46 | 46 | */ |
| 47 | -class Apache_Solr_HttpTransport_CurlNoReuse extends Apache_Solr_HttpTransport_Abstract |
|
| 48 | -{ |
|
| 47 | +class Apache_Solr_HttpTransport_CurlNoReuse extends Apache_Solr_HttpTransport_Abstract { |
|
| 49 | 48 | /** |
| 50 | 49 | * SVN Revision meta data for this class |
| 51 | 50 | */ |
@@ -56,11 +55,9 @@ discard block |
||
| 56 | 55 | */ |
| 57 | 56 | const SVN_ID = '$Id:$'; |
| 58 | 57 | |
| 59 | - public function performGetRequest($url, $timeout = false) |
|
| 60 | - { |
|
| 58 | + public function performGetRequest($url, $timeout = false) { |
|
| 61 | 59 | // check the timeout value |
| 62 | - if ($timeout === false || $timeout <= 0.0) |
|
| 63 | - { |
|
| 60 | + if ($timeout === false || $timeout <= 0.0) { |
|
| 64 | 61 | // use the default timeout |
| 65 | 62 | $timeout = $this->getDefaultTimeout(); |
| 66 | 63 | } |
@@ -98,11 +95,9 @@ discard block |
||
| 98 | 95 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 99 | 96 | } |
| 100 | 97 | |
| 101 | - public function performHeadRequest($url, $timeout = false) |
|
| 102 | - { |
|
| 98 | + public function performHeadRequest($url, $timeout = false) { |
|
| 103 | 99 | // check the timeout value |
| 104 | - if ($timeout === false || $timeout <= 0.0) |
|
| 105 | - { |
|
| 100 | + if ($timeout === false || $timeout <= 0.0) { |
|
| 106 | 101 | // use the default timeout |
| 107 | 102 | $timeout = $this->getDefaultTimeout(); |
| 108 | 103 | } |
@@ -143,11 +138,9 @@ discard block |
||
| 143 | 138 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 144 | 139 | } |
| 145 | 140 | |
| 146 | - public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 147 | - { |
|
| 141 | + public function performPostRequest($url, $postData, $contentType, $timeout = false) { |
|
| 148 | 142 | // check the timeout value |
| 149 | - if ($timeout === false || $timeout <= 0.0) |
|
| 150 | - { |
|
| 143 | + if ($timeout === false || $timeout <= 0.0) { |
|
| 151 | 144 | // use the default timeout |
| 152 | 145 | $timeout = $this->getDefaultTimeout(); |
| 153 | 146 | } |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | const SVN_ID = '$Id:$'; |
| 58 | 58 | |
| 59 | - public function performGetRequest($url, $timeout = false) |
|
| 59 | + public function performGetRequest($url, $timeout = FALSE) |
|
| 60 | 60 | { |
| 61 | 61 | // check the timeout value |
| 62 | - if ($timeout === false || $timeout <= 0.0) |
|
| 62 | + if ($timeout === FALSE || $timeout <= 0.0) |
|
| 63 | 63 | { |
| 64 | 64 | // use the default timeout |
| 65 | 65 | $timeout = $this->getDefaultTimeout(); |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | // set curl GET options |
| 71 | 71 | curl_setopt_array($curl, array( |
| 72 | 72 | // return the response body from curl_exec |
| 73 | - CURLOPT_RETURNTRANSFER => true, |
|
| 73 | + CURLOPT_RETURNTRANSFER => TRUE, |
|
| 74 | 74 | |
| 75 | 75 | // get the output as binary data |
| 76 | - CURLOPT_BINARYTRANSFER => true, |
|
| 76 | + CURLOPT_BINARYTRANSFER => TRUE, |
|
| 77 | 77 | |
| 78 | 78 | // we do not need the headers in the output, we get everything we need from curl_getinfo |
| 79 | - CURLOPT_HEADER => false, |
|
| 79 | + CURLOPT_HEADER => FALSE, |
|
| 80 | 80 | |
| 81 | 81 | // set the URL |
| 82 | 82 | CURLOPT_URL => $url, |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - public function performHeadRequest($url, $timeout = false) |
|
| 101 | + public function performHeadRequest($url, $timeout = FALSE) |
|
| 102 | 102 | { |
| 103 | 103 | // check the timeout value |
| 104 | - if ($timeout === false || $timeout <= 0.0) |
|
| 104 | + if ($timeout === FALSE || $timeout <= 0.0) |
|
| 105 | 105 | { |
| 106 | 106 | // use the default timeout |
| 107 | 107 | $timeout = $this->getDefaultTimeout(); |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | // set curl HEAD options |
| 113 | 113 | curl_setopt_array($curl, array( |
| 114 | 114 | // return the response body from curl_exec |
| 115 | - CURLOPT_RETURNTRANSFER => true, |
|
| 115 | + CURLOPT_RETURNTRANSFER => TRUE, |
|
| 116 | 116 | |
| 117 | 117 | // get the output as binary data |
| 118 | - CURLOPT_BINARYTRANSFER => true, |
|
| 118 | + CURLOPT_BINARYTRANSFER => TRUE, |
|
| 119 | 119 | |
| 120 | 120 | // we do not need the headers in the output, we get everything we need from curl_getinfo |
| 121 | - CURLOPT_HEADER => false, |
|
| 121 | + CURLOPT_HEADER => FALSE, |
|
| 122 | 122 | |
| 123 | 123 | // this both sets the method to HEAD and says not to return a body |
| 124 | - CURLOPT_NOBODY => true, |
|
| 124 | + CURLOPT_NOBODY => TRUE, |
|
| 125 | 125 | |
| 126 | 126 | // set the URL |
| 127 | 127 | CURLOPT_URL => $url, |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public function performPostRequest($url, $postData, $contentType, $timeout = false) |
|
| 146 | + public function performPostRequest($url, $postData, $contentType, $timeout = FALSE) |
|
| 147 | 147 | { |
| 148 | 148 | // check the timeout value |
| 149 | - if ($timeout === false || $timeout <= 0.0) |
|
| 149 | + if ($timeout === FALSE || $timeout <= 0.0) |
|
| 150 | 150 | { |
| 151 | 151 | // use the default timeout |
| 152 | 152 | $timeout = $this->getDefaultTimeout(); |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | // set curl POST options |
| 158 | 158 | curl_setopt_array($curl, array( |
| 159 | 159 | // return the response body from curl_exec |
| 160 | - CURLOPT_RETURNTRANSFER => true, |
|
| 160 | + CURLOPT_RETURNTRANSFER => TRUE, |
|
| 161 | 161 | |
| 162 | 162 | // get the output as binary data |
| 163 | - CURLOPT_BINARYTRANSFER => true, |
|
| 163 | + CURLOPT_BINARYTRANSFER => TRUE, |
|
| 164 | 164 | |
| 165 | 165 | // we do not need the headers in the output, we get everything we need from curl_getinfo |
| 166 | - CURLOPT_HEADER => false, |
|
| 166 | + CURLOPT_HEADER => FALSE, |
|
| 167 | 167 | |
| 168 | 168 | // make sure we're POST |
| 169 | - CURLOPT_POST => true, |
|
| 169 | + CURLOPT_POST => TRUE, |
|
| 170 | 170 | |
| 171 | 171 | // set the URL |
| 172 | 172 | CURLOPT_URL => $url, |
@@ -42,48 +42,48 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | abstract class Apache_Solr_HttpTransport_Abstract implements Apache_Solr_HttpTransport_Interface |
| 44 | 44 | { |
| 45 | - /** |
|
| 46 | - * Our default timeout value for requests that don't specify a timeout |
|
| 47 | - * |
|
| 48 | - * @var float |
|
| 49 | - */ |
|
| 50 | - private $_defaultTimeout = false; |
|
| 45 | + /** |
|
| 46 | + * Our default timeout value for requests that don't specify a timeout |
|
| 47 | + * |
|
| 48 | + * @var float |
|
| 49 | + */ |
|
| 50 | + private $_defaultTimeout = false; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Get the current default timeout setting (initially the default_socket_timeout ini setting) |
|
| 54 | - * in seconds |
|
| 55 | - * |
|
| 56 | - * @return float |
|
| 57 | - */ |
|
| 58 | - public function getDefaultTimeout() |
|
| 59 | - { |
|
| 60 | - // lazy load the default timeout from the ini settings |
|
| 61 | - if ($this->_defaultTimeout === false) |
|
| 62 | - { |
|
| 63 | - $this->_defaultTimeout = (int) ini_get('default_socket_timeout'); |
|
| 52 | + /** |
|
| 53 | + * Get the current default timeout setting (initially the default_socket_timeout ini setting) |
|
| 54 | + * in seconds |
|
| 55 | + * |
|
| 56 | + * @return float |
|
| 57 | + */ |
|
| 58 | + public function getDefaultTimeout() |
|
| 59 | + { |
|
| 60 | + // lazy load the default timeout from the ini settings |
|
| 61 | + if ($this->_defaultTimeout === false) |
|
| 62 | + { |
|
| 63 | + $this->_defaultTimeout = (int) ini_get('default_socket_timeout'); |
|
| 64 | 64 | |
| 65 | - // double check we didn't get 0 for a timeout |
|
| 66 | - if ($this->_defaultTimeout <= 0) |
|
| 67 | - { |
|
| 68 | - $this->_defaultTimeout = 60; |
|
| 69 | - } |
|
| 70 | - } |
|
| 65 | + // double check we didn't get 0 for a timeout |
|
| 66 | + if ($this->_defaultTimeout <= 0) |
|
| 67 | + { |
|
| 68 | + $this->_defaultTimeout = 60; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $this->_defaultTimeout; |
|
| 73 | - } |
|
| 72 | + return $this->_defaultTimeout; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Set the current default timeout for all HTTP requests |
|
| 77 | - * |
|
| 78 | - * @param float $timeout |
|
| 79 | - */ |
|
| 80 | - public function setDefaultTimeout($timeout) |
|
| 81 | - { |
|
| 82 | - $timeout = (float) $timeout; |
|
| 75 | + /** |
|
| 76 | + * Set the current default timeout for all HTTP requests |
|
| 77 | + * |
|
| 78 | + * @param float $timeout |
|
| 79 | + */ |
|
| 80 | + public function setDefaultTimeout($timeout) |
|
| 81 | + { |
|
| 82 | + $timeout = (float) $timeout; |
|
| 83 | 83 | |
| 84 | - if ($timeout >= 0) |
|
| 85 | - { |
|
| 86 | - $this->_defaultTimeout = $timeout; |
|
| 87 | - } |
|
| 88 | - } |
|
| 84 | + if ($timeout >= 0) |
|
| 85 | + { |
|
| 86 | + $this->_defaultTimeout = $timeout; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | } |
| 90 | 90 | \ No newline at end of file |
@@ -40,8 +40,7 @@ discard block |
||
| 40 | 40 | * Convenience class that implements the transport implementation. Can be extended by |
| 41 | 41 | * real implementations to do some of the common book keeping |
| 42 | 42 | */ |
| 43 | -abstract class Apache_Solr_HttpTransport_Abstract implements Apache_Solr_HttpTransport_Interface |
|
| 44 | -{ |
|
| 43 | +abstract class Apache_Solr_HttpTransport_Abstract implements Apache_Solr_HttpTransport_Interface { |
|
| 45 | 44 | /** |
| 46 | 45 | * Our default timeout value for requests that don't specify a timeout |
| 47 | 46 | * |
@@ -55,16 +54,13 @@ discard block |
||
| 55 | 54 | * |
| 56 | 55 | * @return float |
| 57 | 56 | */ |
| 58 | - public function getDefaultTimeout() |
|
| 59 | - { |
|
| 57 | + public function getDefaultTimeout() { |
|
| 60 | 58 | // lazy load the default timeout from the ini settings |
| 61 | - if ($this->_defaultTimeout === false) |
|
| 62 | - { |
|
| 59 | + if ($this->_defaultTimeout === false) { |
|
| 63 | 60 | $this->_defaultTimeout = (int) ini_get('default_socket_timeout'); |
| 64 | 61 | |
| 65 | 62 | // double check we didn't get 0 for a timeout |
| 66 | - if ($this->_defaultTimeout <= 0) |
|
| 67 | - { |
|
| 63 | + if ($this->_defaultTimeout <= 0) { |
|
| 68 | 64 | $this->_defaultTimeout = 60; |
| 69 | 65 | } |
| 70 | 66 | } |
@@ -77,12 +73,10 @@ discard block |
||
| 77 | 73 | * |
| 78 | 74 | * @param float $timeout |
| 79 | 75 | */ |
| 80 | - public function setDefaultTimeout($timeout) |
|
| 81 | - { |
|
| 76 | + public function setDefaultTimeout($timeout) { |
|
| 82 | 77 | $timeout = (float) $timeout; |
| 83 | 78 | |
| 84 | - if ($timeout >= 0) |
|
| 85 | - { |
|
| 79 | + if ($timeout >= 0) { |
|
| 86 | 80 | $this->_defaultTimeout = $timeout; |
| 87 | 81 | } |
| 88 | 82 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @var float |
| 49 | 49 | */ |
| 50 | - private $_defaultTimeout = false; |
|
| 50 | + private $_defaultTimeout = FALSE; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * Get the current default timeout setting (initially the default_socket_timeout ini setting) |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | public function getDefaultTimeout() |
| 59 | 59 | { |
| 60 | 60 | // lazy load the default timeout from the ini settings |
| 61 | - if ($this->_defaultTimeout === false) |
|
| 61 | + if ($this->_defaultTimeout === FALSE) |
|
| 62 | 62 | { |
| 63 | 63 | $this->_defaultTimeout = (int) ini_get('default_socket_timeout'); |
| 64 | 64 | |
@@ -46,49 +46,49 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | interface Apache_Solr_HttpTransport_Interface |
| 48 | 48 | { |
| 49 | - /** |
|
| 50 | - * Get the current default timeout for all HTTP requests |
|
| 51 | - * |
|
| 52 | - * @return float |
|
| 53 | - */ |
|
| 54 | - public function getDefaultTimeout(); |
|
| 49 | + /** |
|
| 50 | + * Get the current default timeout for all HTTP requests |
|
| 51 | + * |
|
| 52 | + * @return float |
|
| 53 | + */ |
|
| 54 | + public function getDefaultTimeout(); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Set the current default timeout for all HTTP requests |
|
| 58 | - * |
|
| 59 | - * @param float $timeout |
|
| 60 | - */ |
|
| 61 | - public function setDefaultTimeout($timeout); |
|
| 56 | + /** |
|
| 57 | + * Set the current default timeout for all HTTP requests |
|
| 58 | + * |
|
| 59 | + * @param float $timeout |
|
| 60 | + */ |
|
| 61 | + public function setDefaultTimeout($timeout); |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Perform a GET HTTP operation with an optional timeout and return the response |
|
| 65 | - * contents, use getLastResponseHeaders to retrieve HTTP headers |
|
| 66 | - * |
|
| 67 | - * @param string $url |
|
| 68 | - * @param float $timeout |
|
| 69 | - * @return Apache_Solr_HttpTransport_Response HTTP response |
|
| 70 | - */ |
|
| 71 | - public function performGetRequest($url, $timeout = false); |
|
| 63 | + /** |
|
| 64 | + * Perform a GET HTTP operation with an optional timeout and return the response |
|
| 65 | + * contents, use getLastResponseHeaders to retrieve HTTP headers |
|
| 66 | + * |
|
| 67 | + * @param string $url |
|
| 68 | + * @param float $timeout |
|
| 69 | + * @return Apache_Solr_HttpTransport_Response HTTP response |
|
| 70 | + */ |
|
| 71 | + public function performGetRequest($url, $timeout = false); |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Perform a HEAD HTTP operation with an optional timeout and return the response |
|
| 75 | - * headers - NOTE: head requests have no response body |
|
| 76 | - * |
|
| 77 | - * @param string $url |
|
| 78 | - * @param float $timeout |
|
| 79 | - * @return Apache_Solr_HttpTransport_Response HTTP response |
|
| 80 | - */ |
|
| 81 | - public function performHeadRequest($url, $timeout = false); |
|
| 73 | + /** |
|
| 74 | + * Perform a HEAD HTTP operation with an optional timeout and return the response |
|
| 75 | + * headers - NOTE: head requests have no response body |
|
| 76 | + * |
|
| 77 | + * @param string $url |
|
| 78 | + * @param float $timeout |
|
| 79 | + * @return Apache_Solr_HttpTransport_Response HTTP response |
|
| 80 | + */ |
|
| 81 | + public function performHeadRequest($url, $timeout = false); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Perform a POST HTTP operation with an optional timeout and return the response |
|
| 85 | - * contents, use getLastResponseHeaders to retrieve HTTP headers |
|
| 86 | - * |
|
| 87 | - * @param string $url |
|
| 88 | - * @param string $rawPost |
|
| 89 | - * @param string $contentType |
|
| 90 | - * @param float $timeout |
|
| 91 | - * @return Apache_Solr_HttpTransport_Response HTTP response |
|
| 92 | - */ |
|
| 93 | - public function performPostRequest($url, $rawPost, $contentType, $timeout = false); |
|
| 83 | + /** |
|
| 84 | + * Perform a POST HTTP operation with an optional timeout and return the response |
|
| 85 | + * contents, use getLastResponseHeaders to retrieve HTTP headers |
|
| 86 | + * |
|
| 87 | + * @param string $url |
|
| 88 | + * @param string $rawPost |
|
| 89 | + * @param string $contentType |
|
| 90 | + * @param float $timeout |
|
| 91 | + * @return Apache_Solr_HttpTransport_Response HTTP response |
|
| 92 | + */ |
|
| 93 | + public function performPostRequest($url, $rawPost, $contentType, $timeout = false); |
|
| 94 | 94 | } |
| 95 | 95 | \ No newline at end of file |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | 39 | // require Apache_Solr_HttpTransport_Response |
| 40 | -require_once(dirname(__FILE__) . '/Response.php'); |
|
| 40 | +require_once(dirname(__FILE__).'/Response.php'); |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * Interface that all Transport (HTTP Requester) implementations must implement. These |
@@ -44,8 +44,7 @@ |
||
| 44 | 44 | * Implementations can then be plugged into the Service instance in order to user their |
| 45 | 45 | * the desired method for making HTTP requests |
| 46 | 46 | */ |
| 47 | -interface Apache_Solr_HttpTransport_Interface |
|
| 48 | -{ |
|
| 47 | +interface Apache_Solr_HttpTransport_Interface { |
|
| 49 | 48 | /** |
| 50 | 49 | * Get the current default timeout for all HTTP requests |
| 51 | 50 | * |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param float $timeout |
| 69 | 69 | * @return Apache_Solr_HttpTransport_Response HTTP response |
| 70 | 70 | */ |
| 71 | - public function performGetRequest($url, $timeout = false); |
|
| 71 | + public function performGetRequest($url, $timeout = FALSE); |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Perform a HEAD HTTP operation with an optional timeout and return the response |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param float $timeout |
| 79 | 79 | * @return Apache_Solr_HttpTransport_Response HTTP response |
| 80 | 80 | */ |
| 81 | - public function performHeadRequest($url, $timeout = false); |
|
| 81 | + public function performHeadRequest($url, $timeout = FALSE); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Perform a POST HTTP operation with an optional timeout and return the response |
@@ -90,5 +90,5 @@ discard block |
||
| 90 | 90 | * @param float $timeout |
| 91 | 91 | * @return Apache_Solr_HttpTransport_Response HTTP response |
| 92 | 92 | */ |
| 93 | - public function performPostRequest($url, $rawPost, $contentType, $timeout = false); |
|
| 93 | + public function performPostRequest($url, $rawPost, $contentType, $timeout = FALSE); |
|
| 94 | 94 | } |
| 95 | 95 | \ No newline at end of file |
@@ -38,42 +38,42 @@ |
||
| 38 | 38 | |
| 39 | 39 | class Apache_Solr_HttpTransportException extends Apache_Solr_Exception |
| 40 | 40 | { |
| 41 | - /** |
|
| 42 | - * SVN Revision meta data for this class |
|
| 43 | - */ |
|
| 44 | - const SVN_REVISION = '$Revision: 54 $'; |
|
| 41 | + /** |
|
| 42 | + * SVN Revision meta data for this class |
|
| 43 | + */ |
|
| 44 | + const SVN_REVISION = '$Revision: 54 $'; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * SVN ID meta data for this class |
|
| 48 | - */ |
|
| 49 | - const SVN_ID = '$Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; |
|
| 46 | + /** |
|
| 47 | + * SVN ID meta data for this class |
|
| 48 | + */ |
|
| 49 | + const SVN_ID = '$Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Response for which exception was generated |
|
| 53 | - * |
|
| 54 | - * @var Apache_Solr_Response |
|
| 55 | - */ |
|
| 56 | - private $_response; |
|
| 51 | + /** |
|
| 52 | + * Response for which exception was generated |
|
| 53 | + * |
|
| 54 | + * @var Apache_Solr_Response |
|
| 55 | + */ |
|
| 56 | + private $_response; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * HttpTransportException Constructor |
|
| 60 | - * |
|
| 61 | - * @param Apache_Solr_Response $response |
|
| 62 | - */ |
|
| 63 | - public function __construct(Apache_Solr_Response $response) |
|
| 64 | - { |
|
| 65 | - parent::__construct("'{$response->getHttpStatus()}' Status: {$response->getHttpStatusMessage()}", $response->getHttpStatus()); |
|
| 58 | + /** |
|
| 59 | + * HttpTransportException Constructor |
|
| 60 | + * |
|
| 61 | + * @param Apache_Solr_Response $response |
|
| 62 | + */ |
|
| 63 | + public function __construct(Apache_Solr_Response $response) |
|
| 64 | + { |
|
| 65 | + parent::__construct("'{$response->getHttpStatus()}' Status: {$response->getHttpStatusMessage()}", $response->getHttpStatus()); |
|
| 66 | 66 | |
| 67 | - $this->_response = $response; |
|
| 68 | - } |
|
| 67 | + $this->_response = $response; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Get the response for which this exception was generated |
|
| 72 | - * |
|
| 73 | - * @return Apache_Solr_Response |
|
| 74 | - */ |
|
| 75 | - public function getResponse() |
|
| 76 | - { |
|
| 77 | - return $this->_response; |
|
| 78 | - } |
|
| 70 | + /** |
|
| 71 | + * Get the response for which this exception was generated |
|
| 72 | + * |
|
| 73 | + * @return Apache_Solr_Response |
|
| 74 | + */ |
|
| 75 | + public function getResponse() |
|
| 76 | + { |
|
| 77 | + return $this->_response; |
|
| 78 | + } |
|
| 79 | 79 | } |
| 80 | 80 | \ No newline at end of file |
@@ -36,8 +36,7 @@ discard block |
||
| 36 | 36 | * @author Donovan Jimenez <[email protected]> |
| 37 | 37 | */ |
| 38 | 38 | |
| 39 | -class Apache_Solr_HttpTransportException extends Apache_Solr_Exception |
|
| 40 | -{ |
|
| 39 | +class Apache_Solr_HttpTransportException extends Apache_Solr_Exception { |
|
| 41 | 40 | /** |
| 42 | 41 | * SVN Revision meta data for this class |
| 43 | 42 | */ |
@@ -60,8 +59,7 @@ discard block |
||
| 60 | 59 | * |
| 61 | 60 | * @param Apache_Solr_Response $response |
| 62 | 61 | */ |
| 63 | - public function __construct(Apache_Solr_Response $response) |
|
| 64 | - { |
|
| 62 | + public function __construct(Apache_Solr_Response $response) { |
|
| 65 | 63 | parent::__construct("'{$response->getHttpStatus()}' Status: {$response->getHttpStatusMessage()}", $response->getHttpStatus()); |
| 66 | 64 | |
| 67 | 65 | $this->_response = $response; |
@@ -72,8 +70,7 @@ discard block |
||
| 72 | 70 | * |
| 73 | 71 | * @return Apache_Solr_Response |
| 74 | 72 | */ |
| 75 | - public function getResponse() |
|
| 76 | - { |
|
| 73 | + public function getResponse() { |
|
| 77 | 74 | return $this->_response; |
| 78 | 75 | } |
| 79 | 76 | } |
| 80 | 77 | \ No newline at end of file |