def update_state_from_location_header(request, polling_state, custom_deserialization_block, final_state_via = FinalStateVia::DEFAULT)
      result = get_async_with_custom_deserialization(request, custom_deserialization_block)

      polling_state.update_response(result.response)
      polling_state.request = result.request
      status_code = result.response.status
      http_method = request.method

      if status_code === 202
        polling_state.status = AsyncOperationStatus::IN_PROGRESS_STATUS
      elsif status_code === 200 || (status_code === 201 && http_method === :put) ||
          (status_code === 204 && (http_method === :delete || http_method === :post || http_method === :get))
        polling_state.status = AsyncOperationStatus::SUCCESS_STATUS

        error_data = CloudErrorData.new
        error_data.code = polling_state.status
        error_data.message = "Long running operation failed with status #{polling_state.status}"

        polling_state.error_data = error_data
        polling_state.resource = result.body
      elsif final_state_via == FinalStateVia::LOCATION && status_code === 404 && http_method === :delete && !polling_state.azure_async_operation_header_link.nil? && !polling_state.location_header_link.nil?
        polling_state.status = AsyncOperationStatus::SUCCESS_STATUS
      else
        fail AzureOperationError, "The response from long running operation does not have a valid status code. Method: #{http_method}, Status Code: #{status_code}"
      end
    end
def update_state_from_location_header(request, polling_state, custom_deserialization_block, final_state_via = FinalStateVia::DEFAULT)
      result = get_async_with_custom_deserialization(request, custom_deserialization_block)

      polling_state.update_response(result.response)
      polling_state.request = result.request
      status_code = result.response.status
      http_method = request.method

      if status_code === 202
        polling_state.status = AsyncOperationStatus::IN_PROGRESS_STATUS
      elsif status_code === 200 || (status_code === 201 && http_method === :put) ||
          (status_code === 204 && (http_method === :delete || http_method === :post || http_method === :get))
        polling_state.status = AsyncOperationStatus::SUCCESS_STATUS

        error_data = CloudErrorData.new
        error_data.code = polling_state.status
        error_data.message = "Long running operation failed with status #{polling_state.status}"

        polling_state.error_data = error_data
        polling_state.resource = result.body
      elsif final_state_via == FinalStateVia::LOCATION && status_code === 404 && http_method === :delete && !polling_state.azure_async_operation_header_link.nil? && !polling_state.location_header_link.nil?
        polling_state.status = AsyncOperationStatus::SUCCESS_STATUS
      else
        fail AzureOperationError, "The response from long running operation does not have a valid status code. Method: #{http_method}, Status Code: #{status_code}"
      end
    end
Updates polling state based on location header for HTTP requests.
 @param request [MsRest::HttpOperationRequest] The url retrieve data from.
 @param polling_state [MsRestAzure::PollingState] polling state to update.
 @param custom_deserialization_block [Proc] custom deserialization method for parsing response.
 @param final_state_via [MsRestAzure::FinalStateVia] Final State via value